Qbasicnews.com
January 26, 2020, 02:53:55 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: 1 [2]
  Print  
Author Topic: data exchange via rs232  (Read 7641 times)
Plasma
Na_th_an
*****
Posts: 1770


WWW
« Reply #15 on: July 15, 2004, 07:23:53 PM »

Yeah, my bad...it should be BaudDiv instead of BaudNum. I don't have a null modem cable right now so I can't test it out, try switching the open and the ComSpeed:

Code:
DEFINT A-Z
DECLARE SUB ComSpeed (Port, Baud&)

' Set the speed and open the port
OPEN "COM2: ,N,8,1" FOR RANDOM AS #1
ComSpeed 2, 115200

' 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, BaudDiv MOD &HFF  ' Lo Byte of Baud Rate
  OUT BaseAddr + 1, BaudDiv \ &H100   ' Hi Byte of Baud Rate
  OUT BaseAddr + 3, OldLSR            ' Disable Divisor Latch

END SUB


@BBQ: How do you know what his "needs" are? Maybe he needs to use QB?
Logged
TheBigBasicQ
*/-\*
*****
Posts: 4550



WWW
« Reply #16 on: July 17, 2004, 12:26:51 PM »

Hey I was just suggesting Cheesy
Logged
A.Sadjadian
New Member

Posts: 18


« Reply #17 on: August 02, 2004, 09:08:03 AM »

THANKS ALL FOR THE REPLIES
the communication via RS232 is working OK (up to 57600 bps NOT at 115200)

But Alas, the Wireless RS232 Cable I purchased proved faulty. It will give me some 3 metres range (instead of at least 50)Manufacturere is supposed to send me a new pair soon.

AND  I have managed to land myself in another qb problem, large program to be modolarised. I am asking for help under a new topic.
Logged
Pages: 1 [2]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!