Posts: 18
Threads: 7
Joined: Feb 2003
help needed to exchange data between 2 computers running DOS and programs in Qbasic. using the rs232 cable( in this case really a Wireless RS232 Cable). one computer is running an inustrial control program and one is the user interface program.( the control computer is installed on a rotating platform )
A.Sadjadian
Posts: 1,752
Threads: 21
Joined: Jun 2002
Is the serial cable a null modem (crossover) cable, or is it a straight-through cable? If it's straight-through, you'll need to get a null modem adapter to make it work.
Once you have a null modem cable, you can use OPEN with "com1:" or "com2:" to communicate between computers. Here's a simple example:
http://www.basicguru.com/files/abc/abc9803/chat.bas
Posts: 4,307
Threads: 63
Joined: May 2003
Quote:Wireless RS232 Cable
What do you mean by wireless cable? Its a contradictory statement :???:
Posts: 18
Threads: 7
Joined: Feb 2003
Dear Plasma
Thank you very much. I would start trying your program right now.
AND. I think my cable is what you call nul . Anyway it has 3 wires pin 2 to pin 3 on the other computer, pin 3 to pin 2 (crossover) and pin 5 to pin 5.
Meanwhile I succeded in sending from one computer to the other and receving ok. However I can not do the reverse i.e. when I run the sending program on one the other can receive but when I exchange the program between the 2 system does not work. Always new problems for Newbie.
Best Regards
A.Sadjadian
Posts: 18
Threads: 7
Joined: Feb 2003
Dear Linux Lover
Salaam
It does seem a contradiction. I searched internet for a wireless RS232 and found this ( I have ordere on yesterday from UK). I suppose the name is to imply that the wireless connection is totally tarnsparent to the user you connect the 2 wireless terminal (small boxes) to the serial DB9 connectors of the 2 computers and they act as if an RS232 cable exist between them, no s/w to install and no drivers to use. Note that I am using DOS for industrial controls systems as I have found it less buggy than windows in some 17 years of use.
A.Sadjadian
Posts: 18
Threads: 7
Joined: Feb 2003
Dear Plasm
Salaam
I had to ad cd0,cs0,ds0 to your program open com string befor it worked with my cable BUT the problem is still there, it works one way only from computer A to b but not from computer B to A. Any recommendations??
Posts: 4,307
Threads: 63
Joined: May 2003
are the two machines identically setup? I mean if you're using any kind of DOS emulation on a windows PC then that will hamper our efforts to track down your problem.
Are you running in pure DOS mode?
Posts: 18
Threads: 7
Joined: Feb 2003
Thanks for the help in the forum
Data exchange is ok now. Trouble was due to faulty connection inside one of the computers. Sorry to bother you.
AND NOW the natural next in line, is 9600 bps the top speed possible with qbasic? Anyway to go up to the top of the com port range of 115000 bps?
Posts: 1,752
Threads: 21
Joined: Jun 2002
9600 is the top speed "natively supported". Of course there is a way past this:
Code:
DEFINT A-Z
DECLARE SUB ComSpeed (Port, Baud&)
' Set the speed and open the port
ComSpeed 2, 115200
OPEN "COM2: ,N,8,1" FOR RANDOM AS #1
' Now send your data however you normally would, for example:
Rqst.Pkt$ = "440900000000d35e"
PRINT #1, Rqst.Pkt$
SLEEP 1
LINE INPUT #1, Resp.Pkt$
' Close the port when you're done
CLOSE #1
SUB ComSpeed (Port, Baud&)
' Based on BaudLatch() sub by Donn Bly
'
' Port = COM Port (1, 2, 3, or 4)
' Baud& = Baud setting (9600, 14400, 19200, 38400, 57600, 115200, etc.)
BaudDiv = 115200 / Baud&
IF BaudDiv = 0 THEN BaudDiv = 1
SELECT CASE Port
CASE 4
BaseAddr = &H2E8 ' com4
CASE 3
BaseAddr = &H3E8 ' com3
CASE 2
BaseAddr = &H2F8 ' com2
CASE ELSE
BaseAddr = &H3F8 ' com1
END SELECT
OldLSR = INP(BaseAddr + 3)
OUT BaseAddr + 3, OldLSR OR &H80 ' Enable the Divisor Latch
OUT BaseAddr + 0, BaudNum MOD &HFF ' Lo Byte of Baud Rate
OUT BaseAddr + 1, BaudNum \ &H100 ' Hi Byte of baud Rate
OUT BaseAddr + 3, OldLSR ' Disable Divisor Latch
END SUB
Posts: 4,307
Threads: 63
Joined: May 2003
AS: This question is a bit off topic but why dont you use C/C++? It's better/faster at this stuff than QB.