hserin repeats characters

LEH

Member
20M2. Tried using serin and serout, did not receive any characters. using hserin characters get repeated infinetly. If I type "R9" I see R999999999999999... on the terminal. I am using an RS232 converter. I will try to attach the program I am using.View attachment rgbpwm.bas
 

hippy

Ex-Staff (retired)
Not entirely sure why it's doing what it is doing, but it might be worthwhile figuring out why SERIN isn't working as that is probably easier to use if you are just expecting letter-digit-digit commands.
 

Technical

Technical Support
Staff member
Code:
Clr:
hserin b2
if b2 <> $FF then
    hserout 0,(b2)
endif
pause 250
hserin b3
if b3 <> $FF then
    hserout 0,(b3)
endif
pause 250
hserin b4
if b4 <> $FF then
    hserout 0,(b4)
endif
pause 150
if b2 = $FF then Clr
hserin is non blocking - it checks for a byte in the buffer, if nothing received it immediately moves onto next part of code. All the pauses in the loop mean you cannot predict which variable will get a particular byte.

You send two bytes "R" and "9"

So what happens above if b4 gets a '9' and b2 is still $FF and no more bytes received - you end up with an infinite loop that will send out multiple 9s.....
 

LEH

Member
Got serin to work now, but none of the comparisons in the program work. So serin B.6,T9600_8,b3 will get my input and the serout will send it back. If I press '9' while the serin is running, and do a serout C.0,T9600_8,#b3 it will send 57 to the monitor, but if I try to do a comparison say if 'b3 = 57 then' the comparison will fail.
 

hippy

Ex-Staff (retired)
Perhaps post your full code so it can be analysed to see what is happening.

SEROUT #B3 showing 57 indicates B3 has value 57 a "9" character in it. Thus "IF B3=57 THEN" or "IF B3="9" THEN" should work.
 

hippy

Ex-Staff (retired)
Most mistakes are D'Oh! moments when discovered, blindingly obvious in hindsight :)

Don't let that put you off asking for help, because sometimes just asking is all it takes to figure the problem out.
 
Top