Serial Port

Discuss whatever you want here--both QB and non-QB related. Anything from the DEF INT command to the meaning of life!

Moderators: Pete, Mods

Post Reply
User avatar
Brandon
Coder
Posts: 47
Joined: Sat Nov 19, 2005 9:24 pm
Location: NY
Contact:

Serial Port

Post by Brandon »

I have 2 PCs and a cable to connect PCs through the serial port. The cable works with the PCs(It worked with File and setings transfer wizard. I would like to use it with QBasic to send variables back and forth. How do I do this?



--------------
http://brandoncornell.com
Patz QuickBASIC Creations
Veteran
Posts: 399
Joined: Wed Mar 02, 2005 9:01 pm
Location: Nashville, Tennessee
Contact:

Post by Patz QuickBASIC Creations »

Basically, you need to have a computer running a sending program, and the other running a recieving program.

Sending program (sends key strokes)

Code: Select all

'PQBC Serial Link Terminal
WHILE KEY$ <> CHR$(27)     'Terminates on ESC
KEY$ = ""
WHILE KEY$ = ""
KEY$=INKEY$
WEND
OUT(&037F,ASC(KEY$))
WEND
I *THINK*...
  • the syntax is OUT(ComPortAddress, ValueToSend)
    &037F is the normal COM1 address
Although I may be wrong.

Recieving program

Code: Select all

X=1:Y=1     'Used to display text with LOCATE
WHILE A <> 27
A=0
WHILE A = 0
A = INP(&037F)
WEND
LOCATE X,Y:PRINT CHR$(A)
X=X+1
IF X > 80 THEN:X=1:Y=Y+1
WEND
Also making another assumption here... (The NULL signal is 0?) If not, both lines that say A=0 needs to be changed to A=(nullsignal)




Also, shouldn't this be posted in QB Q&A?
User avatar
{Nathan}
Veteran
Posts: 1169
Joined: Thu Aug 19, 2004 6:08 pm
Location: The wetlands of central Ohio, USA
Contact:

Post by {Nathan} »

Patz, I skimmed through your code and noticed your comment on X & Y varibles, and how they were used in the LOCATE statement. For some odd reason, in LOCATE the parameters are Y then X, so they should be swapped to:

Code: Select all

LOCATE Y, X
Heh...
(From the demented mind of a crazed 13 year old...)

0_0
Image
Patz QuickBASIC Creations
Veteran
Posts: 399
Joined: Wed Mar 02, 2005 9:01 pm
Location: Nashville, Tennessee
Contact:

Post by Patz QuickBASIC Creations »

OMFG... That is such a NOOBish mistake... I am sorry. Nathan is right. QB always has row then column. So it should be LOCATE Y,X.
Guess I have been graphing on coordinate planes in Algebra too much...
PipeRifle
Coder
Posts: 13
Joined: Tue Dec 13, 2005 12:51 am
Contact:

Post by PipeRifle »

Dear Patz,

Uh... can you really do that? Don't you need settings like baud rate and parity to make it work?
One defeated only when one stopped wanting to win
Patz QuickBASIC Creations
Veteran
Posts: 399
Joined: Wed Mar 02, 2005 9:01 pm
Location: Nashville, Tennessee
Contact:

Post by Patz QuickBASIC Creations »

Don't know... Test it and find out :wink:
Post Reply