Main Site Documentation

Netwroked-Controlled screamer in book .NET& internet of things ,unable to find audio resource


#1

Hello,

I have fez Panda II ( ultimate kit ) and .NET& internet of things book I am trying to run example Networked-controlled screamer, I am getting following error

Error 1 The name ‘Resources’ does not exist in the current context

I have read page explaining how to add resources, can someone help me

here is my complete code,

using System;
using System.Text;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using System.Threading;
using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.Hardware;
using GHIElectronics.NETMF.Net;
using GHIElectronics.NETMF.Net.NetworkInformation;
namespace MFConsoleApplication1
{
public class Program
{
public static void Main()
{
byte[] scare = Resources.GetBytes(Resources.BinaryResources.scream);
// WAV_playback.WAVE wav = new WAV_playback.WAVE(scare);
WAVE wav = new WAVE(scare);
AnalogOut audio = new AnalogOut((AnalogOut.Pin)FEZ_Pin.AnalogOut.An3);
audio.SetLinearScale(0, 255);
byte[] ip = { 192, 168, 1, 176 };
byte[] subnet = { 255, 255, 255, 0 };
byte[] gateway = { 192, 168, 1, 1 };
byte[] mac = { 0x00, 0x88, 0x98, 0x90, 0xD4, 0xE0 };
WIZnet_W5100.Enable(SPI.SPI_module.SPI1, (Cpu.Pin)FEZ_Pin.Digital.Di10,
(Cpu.Pin)FEZ_Pin.Digital.Di7, true);
NetworkInterface.EnableStaticIP(ip, subnet, gateway, mac);
NetworkInterface.EnableStaticDns(gateway);
// start server
HttpListener listener = new HttpListener(“http”, 80);
listener.Start();
while (true)
{
HttpListenerResponse response = null;
HttpListenerContext context = null;
try
{
context = listener.GetContext();
response = context.Response;
// The button is pressed
if (context.Request.HttpMethod == “POST”)
{
audio.Set(scare, wav.GetDataIndex(), wav.GetDataSize(),
wav.GetSampleRate());
}
// Sends response
response.StatusCode = (int)HttpStatusCode.OK;
byte[] HTML = Encoding.UTF8.GetBytes(
"" +

Hosted on FEZ Panda II

” +

Let’s scare some people!

” +
"<form action="" method=“post”>" +
"<input type=“submit” value=“Activate!”>" +
"" +
"");
response.ContentType = “text/html”;
response.OutputStream.Write(HTML, 0, HTML.Length);
response.Close();
}
catch
{
if (context != null)
{
context.Close();
}
}
}
}
}

}


#2

@ akmishra
Please try this:
[ol]Double click on the Resources.resx file. You should see the resources editor open up. At the top should be a menu bar with an “Add Resources” menu.
Click on the Add Resources menu and then select Add existing file…
Select your WAV file and click Open.[/ol]
Your wav file should now be available as a resource.


#3

Hello,

I already did that, that did not solve this problem, anyway I was able to get this compile time error solved by puttting code in a namespace which was same as program, this solved this problem, but now I cannot deploy to hardware , it says deploy failed check your hardware

to make sure my setup, environment and hardware is OK or not, I deployed and ran other programs mentioned in book and that works.

Now I cannot deploy to fez panda II hardware, is code size problem…?

-Thanks
akmishra_99


#4

Could be size problem if you try to put 5MB resource file on panda :slight_smile:

You need a 5KB file.


#5

Hello,

file which I downloaded from GHI web site ( http://www.ghielectronics.com/downloads/FEZ/scream.wav)
is 16KB ( on disk) , how do I check size of executable which gets deployed on FEZ Panda II hardware, before actually deploying it on hardware, so that I can get a proof that size is problem.

-Thanks
akmishra_99