-
nicolas
- Posts: 162
- Joined: Sun Jun 07, 2009 4:32 pm
Post
by nicolas » Tue Oct 20, 2009 1:09 am
Sample project to open, close, send data, and receive data from the serial ports on the Mini2440.
Its pretty basic and is made to work with the DNW tool's baud rate (115200).
Enjoy.
Update:
Due to an ambiguity in the list box, changed to a drop down box for selecting port.
Should now solve any issues opening the port.
Readme:
Code: Select all
Mini2440_Sample_SerialPort
--------------------
This app demonstrates the serial port on the Mini 2440.
It was made to work with the DNW utilities baud rate; 115200.
This sample program was written in VB.Net CF2.0 with Visual Basic 2008 (Code works in VS2005)
It requires the Compact Framework 2.0 be installed on the destination target.
Enjoy.
Nicolas (Nicolas AT Gomez DOT cc)
-
Attachments
-
- Mini2440_Sample_SerialPort_v2.rar
- (20.56 KiB) Downloaded 1260 times
-
nicolas
- Posts: 162
- Joined: Sun Jun 07, 2009 4:32 pm
Post
by nicolas » Sat Nov 14, 2009 11:45 pm
Do note the updated attachment in the original post.
-
amirshah77
- Posts: 17
- Joined: Tue Oct 20, 2009 3:41 pm
Post
by amirshah77 » Tue Dec 01, 2009 8:44 pm
i tried this program on my mini2440 and encountered some problems...
background: on one side is my mini2440, on the other side is my PC running DNW (i also tried HyperTerminal with the same result). used default settings: 115200 baudrate.
what works: i can send strings (i.e. "Hello World!") from the mini2440 to the PC.
what doesn't work: whatever i type on DNW is not displayed by the program. tried single characters and complete strings + enter, multiple times...
when i try to close the port, an error message is displayed. i can't copy-paste it, but here it is in short:
Mini2440_Sample_SerialPort.exe TimeoutException
An error message cannot be displayed because an optional resource assembly containing it cannot be found
at System.IO.Ports.SerialStream.Read()
at System.IO.Ports.SerialStream.Read()
at System.IO.Ports.SerialStream.InternalRead()
at System.IO.Ports.SerialStream.ReadTo()
at System.IO.Ports.SerialStream.ReadLine()
at Mini2440_Sample_SerialPort.Form1.SerialPort1_DataReceived()
at System.IO.Ports.SerialPort.CatchReceivedEvents()
at EventLoopRunner.CallReceiveEvents()
at WorkItem.doWork()
at System.Threading.Timer.ring()
this error message is only displayed when i typed something on DNW. if i don't type anything on the PC side, the port can be closed normally.
from what little i understand, it seems like the ReadLine method is still running when i try to close the port. perhaps it never reaches the condition which allows it to stop (i.e. still waiting for the EOL marker).
(i modified the program so that a MsgBox is displayed every time DataReceived is triggered. from that, i found out that this event is triggered after each character typed in DNW.)
any idea what caused this?
-
nicolas
- Posts: 162
- Joined: Sun Jun 07, 2009 4:32 pm
Post
by nicolas » Tue Dec 01, 2009 8:51 pm
The sample is just that, a sample. Its not perfect.
The error in question is likely due to the receive buffer not getting data when it says data arrived.
Its most likely something I overlooked.
The routine is made so that it makes use of the onComm event, which fires when new data is received. Then it reads whatever there is in the buffer, a mistype here can cause the error you are seeing.
It is trying to grab the data but isnt able too, thus caught in a stop. When you try to close it, its still trying to read, and thus the inability toclose the port.
-
amirshah77
- Posts: 17
- Joined: Tue Oct 20, 2009 3:41 pm
Post
by amirshah77 » Tue Dec 01, 2009 9:21 pm
does the same error occur on your side or is it just me? (haha, after my experience with a faulty board i can never be sure... it can also be due to a bad setting i made while reconfiguring the kernel on Platform Builder...)
i found this while googling, perhaps it is the standard way to use ReadLine:
Try
Dim message As String = _serialPort.ReadLine()
Console.WriteLine(message)
Catch ex As TimeoutException
' Do nothing
End Try
will try it soon. but please tell me if your sample works fine on your side, so that i can be sure that my problem is not due to a hardware fault or a bad PB setting.
thanks.
-
nicolas
- Posts: 162
- Joined: Sun Jun 07, 2009 4:32 pm
Post
by nicolas » Tue Dec 01, 2009 9:41 pm
I have the board put away right now so I cant test it.
When I wrote the code the sample worked, maybe was just luck or I didnt fully test it.
Who is online
Users browsing this forum: No registered users and 2 guests