I'm guessing something ultra-cool.
- Netduino Forums
- → Hachi''s Content
Hachi''s Content
There have been 9 items by Hachi' (Search limited from 14-May 23)
#58549 UltraBlue
Posted by Hachi' on 04 June 2014 - 01:35 PM in General Discussion
#56182 XBee & ND+v1
Posted by Hachi' on 18 February 2014 - 09:44 PM in Netduino Plus 2 (and Netduino Plus 1)
You should think about what series you want to buy: Series 1 or Series 2
#56181 Free article: Windows Phone & netduino
Posted by Hachi' on 18 February 2014 - 09:37 PM in General Discussion
Hi,
there is a free article published in a popular german .NET magazine regarding netduino and Windows Phone: http://www.dotnetpro...rticle4787.aspx
Happy reading.
#55683 Windows Phone controlled car with Netduino and Bluetooth
Posted by Hachi' on 27 January 2014 - 02:00 PM in Project Showcase
Looks like fun!
#54982 STM32F4 mini
Posted by Hachi' on 29 December 2013 - 12:07 AM in Netduino Mini
Nice!
#53843 Threading with ResetEvent and SerialPort problem
Posted by Hachi' on 06 November 2013 - 06:06 AM in General Discussion
Thanks, for watching through my code.
Normally, Thread.Sleep(Timeout.Infinite) works fine, I never had such problems you described.
#53830 Threading with ResetEvent and SerialPort problem
Posted by Hachi' on 04 November 2013 - 08:20 PM in General Discussion
public Byte[] WriteRead(Byte[] bytesToSend){ this.FrameReceived += Device_FrameReceived; this.Write(bytesToSend); // Send bytes to the device Boolean signaled = this.autoResetEvent.WaitOne(); // Wait for response (FrameReceived event) this.FrameReceived -= Device_FrameReceived; if (signaled) { return this.incomingBytes; } else { return null; }}After receiving the bytes, AutoResetEvent.Set is called, to unblock the WriteRead-Method.
private void Device_FrameReceived(Object sender, FrameReceivedEventAgs e){ this.incomingBytes = e.Frame; this.autoResetEvent.Set();}The code above works if it's executed before Thread.Sleep is called in the Main-Method. If the code is executed after Thread.Sleep, the code doesn't work. Device_FrameReceived is never called.
public static void Main(){ device = new Device(); device.FrameReceived += device_FrameReceived; // This will work, because Thread.Sleep isn't called // Byte[] bytes = device.WriteRead(bytesToSend); Thread.Sleep(Timeout.Infinite);}private static void device_FrameReceived(Object sender, FrameReceivedEventAgs e){ // This won't work, beacause Thread.Sleep is already called Byte[] bytes = device.WriteRead(bytesToSend);}I attached a sample application which demonstrates the problem, maybe someone is willing to explain me the problem and how to solve it.
Attached Files
- NetduinoApplication.zip 7.15KB 2 downloads
#53813 Visual Studio 2013?
Posted by Hachi' on 04 November 2013 - 06:24 AM in General Discussion
Hi,
via Microsoft's Download Center you are able to download Visual Studio 2012: http://search.micros...Developer Tools
#53804 Threading, ResetEvent and SerialPort problem
Posted by Hachi' on 03 November 2013 - 09:10 PM in General Discussion
public Byte[] WriteRead(Byte[] bytesToSend){ this.FrameReceived += Device_FrameReceived; this.Write(bytesToSend); Boolean signaled = this.autoResetEvent.WaitOne(); this.FrameReceived -= Device_FrameReceived; if (signaled) { return this.incomingBytes; } else { return null; }}
private void Device_FrameReceived(Object sender, FrameReceivedEventAgs e){ this.incomingBytes = e.Frame; this.autoResetEvent.Set();}Using the WriteRead-Method before calling Thread.Sleep, in the Main-Method, the mechanism works. Once Thread.Sleep is called, the mechanism won't work anymore. I attached an example application which demonstrate the problem. Maybe someone is willing to explain why the demonstration application don't work, and how to fix the problem. To test the application, some random byte have to be generated on COM1. P.S: It's a netduino Mini Application Projects, since I'm not using any netduino Mini specific code, it should run on any netduino, or not?
Attached Files
- NetduinoMiniApplication.zip 186.38KB 0 downloads
- Netduino Forums
- → Hachi''s Content
- Privacy Policy