Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Serial Port in VB2005

Status
Not open for further replies.

victoryhighway2

Programmer
Jul 18, 2005
42
US
Hello,
I'm pretty new to VB2005 and the .NET world in general. I'm trying to write a VB app that uses the serial port to communicate with a hardware device. I'm trying to use the new System.IO.Ports.SerialPort class. I don't want to have to mess with using a COM component through Interop.

I'm having a little bit of difficulty. I can send data through but not recieve. I'm running a serial port monitor application that intercepts all serial traffic between the PC and the device, and it is indicating that the proper response is coming back from the device, but my application is not seeing it.

Is there anyone familiar with this topic that can help me out?

Thanks,
Geoffrey
 
I've never had the need to use serial ports myself, so this is not based on any experience, but I would imagine that you would want to look at the Read method and the DataReceived event:



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Thanks for your replies guys, but I'm afraid that I'm still lost. See, what I'm trying to do is send commands from a PC to a hardware device using the serial (RS232) interface. Once I send the command, I need to wait for a response from the device. This was quite easy in VB6, aka just sit in a do loop until you've recieved the right number of bytes or you've timed out. I haven't yet found a way of doing this in VB. I've been looking into Dick Grier's terminal application. I've set up my application similar to his (except I'm not using multi-threading). I don't know why, but the SerialDataRecieved event (which currently only displays the serialport.readexisting in a messagebox) never fires. I have the RecievedBytesThreshold propery set to 1 byte. My serial port monitor tells me that data was recieved, but my app never sees it.

I'm really at a loss and am starting to get frustrated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top