- Netduino Forums
- → <Jeremy>'s Content
<Jeremy>'s Content
There have been 31 items by <Jeremy> (Search limited from 27-September 23)
#18471 Dangershield
Posted by <Jeremy> on 27 September 2011 - 08:45 AM in Project Showcase
#18810 PCB
Posted by <Jeremy> on 05 October 2011 - 08:16 AM in General Discussion
#18766 PCB
Posted by <Jeremy> on 04 October 2011 - 01:01 PM in General Discussion
#18076 BinaryWriter?
Posted by <Jeremy> on 16 September 2011 - 10:51 AM in Netduino Plus 2 (and Netduino Plus 1)
#18033 Sockets
Posted by <Jeremy> on 15 September 2011 - 07:52 AM in Netduino 2 (and Netduino 1)
#18035 Netduino Plus + ID-20 (again!)
Posted by <Jeremy> on 15 September 2011 - 08:08 AM in Netduino Plus 2 (and Netduino Plus 1)
#18153 My first project with netduino
Posted by <Jeremy> on 18 September 2011 - 07:23 PM in Project Showcase
#32272 This looks like a bug in InterruptPort
Posted by <Jeremy> on 19 July 2012 - 09:08 AM in General Discussion
#32239 This looks like a bug in InterruptPort
Posted by <Jeremy> on 18 July 2012 - 10:56 PM in General Discussion
#17758 Reading data chunks from a COM port question
Posted by <Jeremy> on 08 September 2011 - 01:58 PM in Netduino 2 (and Netduino 1)
#17851 Reading data chunks from a COM port question
Posted by <Jeremy> on 11 September 2011 - 11:39 AM in Netduino 2 (and Netduino 1)
#17784 Reading data chunks from a COM port question
Posted by <Jeremy> on 08 September 2011 - 10:14 PM in Netduino 2 (and Netduino 1)
#18015 HMC5883L Magnetometer Netduino Code
Posted by <Jeremy> on 14 September 2011 - 09:54 PM in Project Showcase
Attached Files
- HMC5883L.cs 4.73KB 225 downloads
- AbstractI2CDevice.cs 1.9KB 170 downloads
- Program.cs 588bytes 173 downloads
#21554 HMC5883L Magnetometer Netduino Code
Posted by <Jeremy> on 10 December 2011 - 06:10 PM in Project Showcase
#32361 Increasing the resolution of the system timer
Posted by <Jeremy> on 20 July 2012 - 03:18 PM in Beta Firmware and Drivers
#32863 Increasing the resolution of the system timer
Posted by <Jeremy> on 29 July 2012 - 12:27 AM in Beta Firmware and Drivers
#32859 Increasing the resolution of the system timer
Posted by <Jeremy> on 28 July 2012 - 11:31 PM in Beta Firmware and Drivers
#17836 Working with UART
Posted by <Jeremy> on 10 September 2011 - 06:17 PM in Visual Studio
I've been having a look at the problem you've described (since I've been working on some serial port things myself).
First, I'm assuming you've got D0 (COM1 Rx) connected to D3 (COM2 Tx), and D1 (COM1 Tx) connected to D2 (COM2 Rx) here.
Given that, if you look in the SerialPortHelper.cs class, the serialPort variable is declared as static (as are buffer and
bufferlength). I think what's happening is that since you've instantiated two separate ports in your class, you're actually sharing
resources between them. So when an event is fired to say "data has been written to COM1", the code reacts to that event
by trying to read from COM2. If you leave the serialPort variable as static, and change the serialPort_DataReceived
method to look like the code below, you'll see what i mean:
private void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e) { // i expect these to both return the same port // if serial port is static, i find they're different. Debug.Print("serial port name = " + serialPort.PortName); Debug.Print("sender name = " + ((SerialPort)sender).PortName); lock (buffer) { if (serialPort.BytesToRead > 0) { int bytesReceived = serialPort.Read(buffer, bufferLength, bufferMax - bufferLength); if (bytesReceived > 0) { bufferLength += bytesReceived; if (bufferLength >= bufferMax) throw new ApplicationException("Buffer Overflow. Send shorter lines, or increase lineBufferMax."); } } } }
So basically I think if you use the method above, and remove the static modifier from the serialPort variable, you
should make some progress. You might want to remove static from the other two member variables too.
I guess you'll also have noticed I added a little bit to that code to check if there's at least one byte to read from serialPort.
Stepping through your program slowly in debug mode gives me different behaviour to when I just run it
without breakpoints - I found there was an exception in this method because whereas we've been notified that data has
been received, when I actually look at the serialPort.BytesToRead property I find that there's nothing there. I couldn't
work out why the event was being fired, if you have an answer I would be really interested to know!
But this looks like a great library, it's interesting to me as well.
I hope this helps - let me know how it works out.
Jeremy
#32238 DHT11 Temperature Sensor
Posted by <Jeremy> on 18 July 2012 - 10:38 PM in Netduino 2 (and Netduino 1)
#32207 DHT11 Temperature Sensor
Posted by <Jeremy> on 18 July 2012 - 04:22 PM in Netduino 2 (and Netduino 1)
#18802 Help porting Arduino code for FM radio module
Posted by <Jeremy> on 04 October 2011 - 09:48 PM in General Discussion
Attached Files
- AbstractI2CDevice.cs 2.13KB 52 downloads
- Program.cs 971bytes 42 downloads
- Si4703.cs 12.75KB 71 downloads
#18765 Help porting Arduino code for FM radio module
Posted by <Jeremy> on 04 October 2011 - 12:58 PM in General Discussion
#18809 Help porting Arduino code for FM radio module
Posted by <Jeremy> on 05 October 2011 - 07:41 AM in General Discussion
#18815 Help porting Arduino code for FM radio module
Posted by <Jeremy> on 05 October 2011 - 10:52 AM in General Discussion
#19056 Help porting Arduino code for FM radio module
Posted by <Jeremy> on 11 October 2011 - 10:55 PM in General Discussion
( (this.Si4703_Registers[RDSB] & 0x00FF) & 0x3) * 2;
So this time, each of the pairs of letters will be associated with the numbers 0, 2, 4, and 6, and therefore you can determine the correct order of the letters and what letters come first.
Jeremy
- Netduino Forums
- → <Jeremy>'s Content
- Privacy Policy