-->
Page 1 of 3

serial2input

PostPosted: Thu Feb 23, 2017 8:54 am
by Lagnus
Hello,
i have the following problem:
I send 7 bytes to the esp (decimal): 2 5 22 0 4 3 22
I use the following code and get : 2 5 22 0 0 0 0
(if i send 11 bytes system hangs up)

serial2begin 9600, 14 , 12
textbox z$
serial2branch [serial2in]
wait

[serial2in]
serial2input a$
l = len(a$)
for i = 1 to l
b$ = asc(mid(a$,i,1))
z$ = z$ & " " & b$
next i
return

Re: serial2input

PostPosted: Thu Feb 23, 2017 1:58 pm
by Electroguard
I seem to remember noticing in the past that 0 (zero) was being interpreted as a serial 'end of string' character which caused the partial string to be transmitted, therefore was unable to be transmitted as a numeric character representing zero.
So effectively, a string of numbers containing 0 or 00 or 000 etc will be interpreted as multiple strings of fewer numberic character lengths.
Should be easy enough for you to test for if you are aware.

Re: serial2input

PostPosted: Fri Feb 24, 2017 6:27 am
by Lagnus
If i send 7 bytes without zero's it works,
But if i send 11 bytes (without zero's) system hangs up.
So how could i solve this?

Is there a kind of watchdog in the espbasic?

Re: serial2input

PostPosted: Fri Feb 24, 2017 9:34 am
by Electroguard
You are reading and manipulating the serial input as ascii characters, therefore you need to be sending appropriate ascii codes to represent the numbers rather than the actual numeric byte values - which will get interpreted as ascii codes... and ascii codes lower than 32 (space) are seen as control codes which may do something unwanted and possibly cause weird symptoms.