Shared COM1 Issues
#1
Posted 28 September 2012 - 06:33 PM
#2
Posted 28 September 2012 - 07:28 PM
- Joshk likes this
#3
Posted 28 September 2012 - 11:44 PM
#4
Posted 01 October 2012 - 03:55 AM
I added a bit of code so my code does not setup a COM if pin Digital_13 is low. That allows the debugger mode to work fine if I hold Digital_13 low during boot. But when running my code when the mini was sent data the DataReceived event was not firing. I discovered if I prevent the NEW function from finalizing the debugger would not get around to starting... so I jammed the NEW function with an indefinite thread sleep as the last line of code. Everything seems to still work, and DataReceived is firing every time I press a key, as confirmed by the data the mini is sending back to my terminal each time I press a key. But I can't seem to get the correct data out of the buffer. It seems the buffer is empty by the time the event fires. I did seriously tampered with the code during my testing, maybe I broke it, or maybe the buffer is being sucked empty by framework code first.
Any insight or advice?
Private Sub serialPort_DataReceived(sender As Object, e As System.IO.Ports.SerialDataReceivedEventArgs) Handles serialPort.DataReceived Try Dim Buffer As Byte() = New Byte(serialPort.BytesToRead - 1) {} serialPort.Read(Buffer, 0, Buffer.Length) 'Load "Buffer" Print(serialPort.BytesToRead.ToString) _buffer += New String(Encoding.UTF8.GetChars(Buffer)) ' Have we received a full line of data? Dim Pos As Integer = _buffer.IndexOf("5") ' Data gets parsed If Pos >= 0 Then Dim Data As String = Me._buffer.Substring(0, Pos) Me._buffer = Me._buffer.Substring(Pos + 2) Print(Data) RaiseEvent LineReceived(Data) End If Catch ex As Exception Print(ex.ToString) End Try End Sub
#6
Posted 01 October 2012 - 10:48 AM
#7
Posted 01 October 2012 - 01:45 PM
#8
Posted 01 October 2012 - 07:01 PM
Just FYI...if you drive the DTR pin high during powerup, the Mini will go into TinyBooter mode so you can erase your app.
Chris
Wow, maximum basic stamp compatability!
#9
Posted 01 October 2012 - 08:24 PM
Generally, you will want to reserve one serial port on Netduino Mini for a debug connection to the PC.Yea that's really handy, thanks Chris. What are your thoughts on trying to run a program on a Mini that uses both Com ports?
That said, I'm pretty sure that some users are using both serial ports in their applications. It's possible that NETMF support for this may have changed between NETMF 4.1 and NETMF 4.2, but I'm not aware of any specific changes.
One final note...if you're simply trying to send data to the PC from time to time, have you thought about using Debug.Print to do so? It will send the data over the serial port. Then you could parse that data out on the PC or use MFDeployEngine to capture the data post-parsing. As a bonus you wouldn't be blocking the debug port, so it would be easier to reconnect and redeploy your app.
Chris
- Joshk likes this
#10
Posted 02 October 2012 - 04:38 AM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users