Catch data from Serial Port

Blake81

Well-known member
Joined
Feb 23, 2006
Messages
304
Location
Georgia, USA
Programming Experience
1-3
I have a Uniden police scanner which has a serial connection. The Uniden site has trial software which allows you to control the scanner from the computer. I'd like to see if I'm able to make my own software to do this. I'm using a USB to Serial converter to plug the scanner into one of my USB ports, and I'd like to be able to catch all of the data to and from COM7 and put it in a file so I can look at it to see if I can figure out how to send commands to the scanner. I tried making a sample app that was supposed to put the data in a text box when I hit a button, but when I hit the button, the app just sat there doing nothing. It's almost like it wasn't going to put anything in the textbox until it was done receiving data, which wasn't going to happen. Is it possible to do this? Thanks.
 
ComPort Class in VB.NET 2005

See VS 2005 help:
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_vbalr/html/244ede4e-25b7-445b-9fd6-163550cce193.htm

The My.Computer.Ports object provides a straightforward entry point for accessing the .NET Framework serial port class,
 
Im not sure what code youve written but off the top of my head, a service to do this would be something like this:

VB.NET:
[FONT=Courier New][SIZE=2][FONT=Courier New][COLOR=blue][COLOR=blue]Private[/COLOR][/COLOR] [COLOR=blue][COLOR=blue]WithEvents[/COLOR][/COLOR] serial  [COLOR=blue][COLOR=blue]As[/COLOR][/COLOR]  System.IO.Ports.SerialPort[/FONT][/SIZE][/FONT][SIZE=2]

[/SIZE][FONT=Courier New][SIZE=2][FONT=Courier New][COLOR=blue][COLOR=blue]Protected[/COLOR][/COLOR] [COLOR=blue][COLOR=blue]Overrides[/COLOR][/COLOR] [COLOR=blue][COLOR=blue]Sub[/COLOR][/COLOR] OnStart([COLOR=blue][COLOR=blue]ByVal[/COLOR][/COLOR] args() [COLOR=blue][COLOR=blue]As[/COLOR][/COLOR] [COLOR=blue][COLOR=blue]String[/COLOR][/COLOR])[/FONT][/SIZE][/FONT][SIZE=2]
 [/SIZE][FONT=Courier New][SIZE=2][FONT=Courier New]   serial = [COLOR=blue][COLOR=blue]New[/COLOR][/COLOR]  System.IO.Ports.SerialPort()[/FONT][/SIZE][/FONT][SIZE=2]
[/SIZE][FONT=Courier New][SIZE=2][FONT=Courier New][COLOR=blue][COLOR=blue]End[/COLOR][/COLOR] [COLOR=blue][COLOR=blue]Sub[/COLOR][/COLOR][/FONT][/SIZE][/FONT][SIZE=2]
 
[/SIZE] [FONT=Courier New][SIZE=2][FONT=Courier New][COLOR=blue][COLOR=blue]Private[/COLOR][/COLOR] [COLOR=blue][COLOR=blue]Sub[/COLOR][/COLOR] DataReceived(sender [COLOR=blue][COLOR=blue]As[/COLOR][/COLOR] [COLOR=blue][COLOR=blue]Object[/COLOR][/COLOR], e [COLOR=blue][COLOR=blue]As[/COLOR][/COLOR]  System.IO.Ports.SerialDataReceivedEventArgs) [COLOR=blue][COLOR=blue]Handles[/COLOR][/COLOR]  serial.DataReceived[/FONT][/SIZE][/FONT][SIZE=2]
 [/SIZE][FONT=Courier New][SIZE=2][FONT=Courier New]   [COLOR=SeaGreen]'do stuff here[/COLOR]  [/FONT][/SIZE][/FONT][SIZE=2]
[/SIZE][FONT=Courier New][SIZE=2][FONT=Courier New][COLOR=blue][COLOR=blue]End[/COLOR][/COLOR] [COLOR=blue][COLOR=blue]Sub[/COLOR][/COLOR][/FONT][/SIZE][/FONT][SIZE=2]
 
[/SIZE] [FONT=Courier New][SIZE=2][FONT=Courier New][COLOR=blue][COLOR=blue]Protected[/COLOR][/COLOR] [COLOR=blue][COLOR=blue]Overrides[/COLOR][/COLOR] [COLOR=blue][COLOR=blue]Sub[/COLOR][/COLOR] OnStop()[/FONT][/SIZE][/FONT][SIZE=2]
 [/SIZE][FONT=Courier New][SIZE=2][FONT=Courier New]   serial.Dispose()[/FONT][/SIZE][/FONT][SIZE=2]
[/SIZE] [FONT=Courier New][SIZE=1][FONT=Courier New][SIZE=2][COLOR=blue][COLOR=blue]End[/COLOR][/COLOR][/SIZE][COLOR=blue][COLOR=blue][SIZE=2] Sub[/SIZE][/COLOR][/COLOR][/FONT][/SIZE][/FONT]
 
Remember hypertrm program comes with some Windows or can
probably download. I think you can connect it to com [n] ports
but don't know about USB. If this works, you would at least know
whats possible with .Net
 
Back
Top