×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Format of data out of serial port

Format of data out of serial port

Format of data out of serial port

(OP)
I have a program working, to send a single charactor out the serial port under QBASIC. I send the charactor, then wait, then if no response is found in the rx buffer, I send again, max of three tries, then onto next charactor.

My loop is simply "for adres = 1 to 10"
then the variable adres is used as :
"print #1,adres"

Im using this to output a address for a microchip polling project.

My question is simply this : when I do the above loop and Print # 1 function, what is the format of that variable? Is is ASCII, hex, binary or what???? My guess is ASCII, and that would be 7 bits, and the port is setup for 9600, 8 bits, no parity, and 1 stop bit.

Anyone been into this before??

Randy McKenzie

RE: Format of data out of serial port

Printing the ascii character into an 8 bit character cell, which can be considered hex or binary as those are reprentations of the character you are dealing with.
With your code you are getting a terminator after the character you are sending.

Sounds suspiciously like homework, but for the moment will let it excape the flag. But somebody else may take offense.

Ed Fair
Give the wrong symptoms, get the wrong solutions.

RE: Format of data out of serial port

(OP)
Actually this is for a Amateur radio project Im working on. What is the added bit, making the 7 bit ASCII into 8 bit?? I desire a binary 8 bit unit....can QBASIC send binary instead of ASCII???? Or do I convert from ASCII to binary using the CHR$ stuff? Been along time since my BASIC class in High School.....

The desired goal is to have eventually numerous addressable PICS, each monitoring various items, connected via a RS485 network, polled by a master PC.

Been a LONG time since I had homework.....

Randy McKenzie
Actual age : 35, but sometimes feel 65, but wife says I act like 5......

RE: Format of data out of serial port

7bit ascii is simply chr$(0) - chr$(127)
8bit is chr$(0) - chr$(255)

when you send info to a serial port you send the chr$(#) or
equiv. Qbasic (or QuickBasic) or any other programming language together with the operating system will take care of sending the bits (serial ports receive/send 1 bit at a time).

Some of the control codes (chr$(1)-chr$(29)) are typically
used to tell the receiver you are through sending. This is
part of (but certainly not all of) what is known as "handshake". (BTW even chr$(0) is used making up what is known as an ASCIIZ string (null terminator).

there are lots of examples of sending info over a serial port. You might look at allbasiccode.com or QB45.com

FYI it's been a lot longer for me (since i've had homework).
LOL
 

RE: Format of data out of serial port

Wouldn't consider the terminator as handshake. Printing as shown you would get the character plus a 0Dh and an 0ah, otherwise known as carraige return and linefeed.
You probably would want to suppress those with the semicolon.
And I assume that you would build in some time delay for checking the return code, since the earliest you could get a valid one would be 2 character cell widths after you wrote to the data register, which can be a while after you do a print statement.
To get around the variable delay of the print statement you might want to consider the poke/peek pair.

Ed Fair
Give the wrong symptoms, get the wrong solutions.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close