serial input


Author Message
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 1693
Posted: 07:19am 10 Jun 2025      

Example of my multi-drop:

I always use binary (BIN2STR, STR2BIN)
I always have a header &HAA (&b1010 1010)

I don't like using PAUSE, prefer to look for single characters and process them immediately.

do

 if loc(2) then
   b1 = asc(input$(1,2))
   if b1=&haa then             'header byte
     do:loop until loc(2)
     b1 = asc(input$(1,2))
     if b1 = addr then         'is it my address byte?
       'You talkin to me?
       accum=""
       for i = 1 to 8          'always 8 bytes of data
         do:loop until loc(2)
         accum = accum + input$(1,2)
       next
       myvalue = str2bin(int64,accum,big)
       do:loop until loc(2)
       checksum = asc(input$(1,2))
     end if
   end if
 end if

loop


Obviously, this could freeze but that would mean a serious problem and watchdog would happen.

@Grogster: I think that, conservatively, 10ms = 1000 lines of execution(?)