Hi,
I wrote this code ...
Alles anzeigen
why does not I receive the string correctly?
es. : 02 00 03 33 30 59 03 58
receives: 00 03 03 58 ???
I wrote this code ...
BASCOM-Quellcode
- $regfile = "m1284def.dat"
- $crystal = 16000000
- $baud1 = 9600
- $hwstack = 40 ' default use 32 for the hardware stack
- $swstack = 40 ' default use 10 for the SW stack
- $framesize = 40
- Config Lcdpin = Pin , Db4 = Porta.3 , Db5 = Porta.2 , Db6 = Porta.1 , Db7 = Porta.0 , E = Portc.5 , Rs = Portc.6
- Config Lcd = 16 * 2
- Config Com2 = 9600 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
- Open "com2:" For Binary As #2
- Config Portd.6 = Output
- Declare Sub Bip
- Dim Cmdrx As String * 254
- Dim Rx_cmd , Ric As Byte
- Bip
- Enable Interrupts
- Cls
- Locate 1 , 1
- Lcd "HELLO"
- Wait 2
- Bip
- Print #2 , Chr(&H02) ; Chr(&H00) ; Chr(&H02) ; Chr(&H33) ; Chr(&H30) ; Chr(&H03) ; Chr(&H00); 'POWER ON
- Cmdrx = ""
- Do
- Rx_cmd = Ischarwaiting(#2) 'CONTROLLA SE E' STATO RICEVUTO UN CARATTERE
- If Rx_cmd = 1 Then
- Rx_cmd = Waitkey(#2) 'RITORNA IL VALORE DECIMALE RICEVUTO
- Ric = 1
- Cmdrx = Cmdrx + Hex(rx_cmd) 'INSERISCE I CARATTERI IN UNA STRINGA FINO A QUANDO LA TRASMISSIONE NON TERMINA
- Waitms 1
- Else
- If Ric = 1 Then
- Ric = 0
- Bip
- Waitms 500
- Locate 2 , 1
- Lcd Cmdrx '??????????????
- If Cmdrx = "06" Then
- Waitms 500
- Bip
- Print #2 , Chr(&H05);
- End If
- End If
- Cmdrx = ""
- End If
- Loop
- End
es. : 02 00 03 33 30 59 03 58
receives: 00 03 03 58 ???