User Tools

Site Tools

한국어

wikiblog:cublocexample1:index

RS232C Send and Receive

When a “Devie” send a command like “A”+CR (hex 13), CUBLOC answer that.

#include "MSB6XX"             '1
Dim ln As Integer
Dim st1 As String *30
Opencom 1,115200,3,50,150     '2
On Recv1 Gosub datarecv_rtn   '3
 
Set Until 1,10,13             '4
 
Do
Loop
 
datarecv_rtn:
 
ln = Blen(1,0)
st1 = Getstr(1,ln)            '5
st1 = Left(st1,1)             '6
 
 
If st1 = "A" Then Goto process_A       '7
If st1 = "B" Then Goto process_B
If st1 = "C" Then Goto process_C
Return
​
process_A:
Putstr 1,"A0001"                       '8
Put 1,13,1
Return
 
​process_B:
Putstr 1,"B0002"
Put 1,13,1
Return
 
​process_C:
Putstr 1,"C0003"
Put 1,13,1
Return
  1. This code use MSB6xx series
  2. I connect RS232C ch1 and Baudrate is 115200
  3. event routine is “datarecv_rtn”
  4. wait until receive hex13 and than goes to “datarecv_rtn”
  5. read all command from “device”
  6. check very first charactor
  7. branch
  8. answer something

Charles's Blog

wikiblog/cublocexample1/index.txt · Last modified: 2022/07/09 09:27 by COMFILE Technology