SimpleLAN and UDP with a PICAXE

Ruzzz

Member
I have a SimpleLAN and I'm trying to get it to send and recieveUDP messages.
I've managed to get the PICAXE ( a 28x1 ) to send UDP messages via the SimpleLAN and to read the status variable of the SimpleLAN, but I cant find out how to read the UDP messages. I can see the bit to indicate a UDP message goes high when it recieves one, but I cant find a command to read the UDP message. The manual isnt very helpful on recieving UDP. Anyone used this combo ?
 

lbenson

Senior Member
Here, extracted from working code, is what I use to retrieve a UDP message from the SimpleLan module. Hope I didn't leave out anything crucial.

Code:
    serout SLANoutpin, t2400, ("!AT0ST")  ' get status
    b12 = 10
    do
      if hserinflag = 1 then 
        b12 = 0
      else
        pause 100
        dec b12
      endif
    loop while b12 > 0
    if hserinflag = 0 then 
      sertxd("SimpleLan not responding with status")
    else
      pause 100  ' allow transmission to complete
      hserinflag = 0
      ptr = 0
      b0 = @ptr  ' get status byte

      if bit4 = 1 then  ' %00010000
'        sertxd(" UDP Message: ",13,10)
        hserptr = 0
        serout SLANoutpin, t2400, ("!AT0RBM" )  ' get UDP message (from 22002)
        pause 400  ' allow 64 bytes to be sent (@ 300/min)
        gosub get_hser_data
'        sertxd("Back from UDP call: ",13,10)
      endif
'      sertxd(13,10)
      hserptr = 0
      hserinflag = 0
    endif  ' end of processing of SimpleLan status flag

' more code here
 

steliosm

Senior Member
Well, as far I can say, that routine just gets the data out from the scratchpad memory. Not hard to implemented by your self, since you already know the pointer starting position (0) and the maximum length of a UDP package that can be received from the SimpleLan (64 bytes).
 

lbenson

Senior Member
My get_hser_data is a hairy mess 220 lines long, because in that routine I process the UDP message, which may command many things. As steliosm suggests, you can walk through the data (which is in the scratchpad) with "b13 = @ptrinc" in a loop.
 
Top