serial port communication question
davejames
Posts: 4,047
Hi All,
Noticed something odd tonight during my experiments in setting up serial port communication from a BS2 and VB2005 program.
First - the BS2 is running a loop where it does a SEROUT at 2400 baud 8NP <text> and then does a SERIN at 2400 baud 8NP waiting for a DEC with a time out of 3 seconds.·The code tokenizes, downloads, and runs with no errors.
Second - HyperTerm has been configured for 2400 baud 8NP, and when connected to COM4 (the BS2 via a Parallax Serial to USB converter), the text from from the SEROUT is recognized properly; a number can be entered and recognized by the BS2.
All is well at this point.
Where the confusion arises is when I run a VB2005 app that reads the available COM ports, the baud rate is always 9600 even for COM4 that the BS2 is using.· I would think I'd read back 2400 as that's the SEROUT setting.
Anybody have any ideas?· Maybe I'm continually reading the baud rate characteristic from one COM port only...
Regards,
DJ
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Instead of:
"Those who can, do.· Those who can't, teach." (Shaw)
I prefer:
"Those who know, do.· Those who understand, teach." (Aristotle)
·
Noticed something odd tonight during my experiments in setting up serial port communication from a BS2 and VB2005 program.
First - the BS2 is running a loop where it does a SEROUT at 2400 baud 8NP <text> and then does a SERIN at 2400 baud 8NP waiting for a DEC with a time out of 3 seconds.·The code tokenizes, downloads, and runs with no errors.
Second - HyperTerm has been configured for 2400 baud 8NP, and when connected to COM4 (the BS2 via a Parallax Serial to USB converter), the text from from the SEROUT is recognized properly; a number can be entered and recognized by the BS2.
All is well at this point.
Where the confusion arises is when I run a VB2005 app that reads the available COM ports, the baud rate is always 9600 even for COM4 that the BS2 is using.· I would think I'd read back 2400 as that's the SEROUT setting.
Anybody have any ideas?· Maybe I'm continually reading the baud rate characteristic from one COM port only...
Regards,
DJ
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Instead of:
"Those who can, do.· Those who can't, teach." (Shaw)
I prefer:
"Those who know, do.· Those who understand, teach." (Aristotle)
·
Comments
I expect Unsoundcode will have a more definitive analysis of the issue with VB.
Cheers,
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·
When communicating with a serial port you have set the baudrate property before you try opening the port.
I hope I understood the problem.
Jeff T.
OK - I'm obviously missing something here as I have no experience in serial communication between a BS2 and a VB2005 app.
Do I really have to set up the serial port characteristics prior to opening it?!?! Is there no way I can just say "hey COM4, what's your baud rate?"
Thanks,
DJ
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Instead of:
"Those who can, do.· Those who can't, teach." (Shaw)
I prefer:
"Those who know, do.· Those who understand, teach." (Aristotle)
·
I have never tried either but did once see an example in C# of the latter.
You could try googling it , if you find a VB example and need help adapting it for your needs let me know.
Jeff T.
DJ
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Instead of:
"Those who can, do.· Those who can't, teach." (Shaw)
I prefer:
"Those who know, do.· Those who understand, teach." (Aristotle)
·