Shop OBEX P1 Docs P2 Docs Learn Events
serial port communication question — Parallax Forums

serial port communication question

davejamesdavejames Posts: 4,047
edited 2009-06-19 15:02 in BASIC Stamp
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)
·

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2009-06-17 11:58
    Does your VB2005 app actually do a speed check or is it just checking that the port is in use? If the Stamp isn't sending data at the time VB is checking, it may just use a default setting. Does the app work with any other serial input ( another device or computer running Hyperterminal)?

    I expect Unsoundcode will have a more definitive analysis of the issue with VB.

    Cheers,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2009-06-17 12:23
    Hi Dave, Tom is right when he say's theat VB uses a default setting (9600).

    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.
  • davejamesdavejames Posts: 4,047
    edited 2009-06-18 04:09
    ...well, you both probably understood what I thought I was saying...

    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)
    ·
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2009-06-18 16:02
    Hi Dave, there are ways to automatically detect baud rate. You can keep opening and closing the port at different bauds until you get comprehensible communication or you can measure the bit rate time and determine baud through calculation.

    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.
  • davejamesdavejames Posts: 4,047
    edited 2009-06-19 15:02
    ok Jeff, I'll sniff around a bit more.

    DJ

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Instead of:

    "Those who can, do.· Those who can't, teach." (Shaw)
    I prefer:
    "Those who know, do.· Those who understand, teach." (Aristotle)
    ·
Sign In or Register to comment.