Shop OBEX P1 Docs P2 Docs Learn Events
PINK, reading the contents of the NB0BM register with the BS2 — Parallax Forums

PINK, reading the contents of the NB0BM register with the BS2

MarcelMarcel Posts: 32
edited 2006-09-18 17:20 in BASIC Stamp
Hi,
I read several posts about the "UDP" subject but haven't found a solution to the following problem.
I have a database program that sends a UDP message in XBasic to the PINK. It is recieved by the PINK and I can read the message on the PINK's webpage. Now I want to read the UDP message from the NB0BM register with the BS2.
dim socketaddress as P 
Sockets.datagram_send("192.168.2.6", 10000, "UDP_X10")

I wrote the next program to try to read the NB0BM register. But the PINK or BS2 freezes when it encounters the show routine.

' {$STAMP BS2} 
' {$PBASIC 2.5} 
' M.Kollenaar 
' September 2006 
' Polling the PINK to act on recieved UDP messages. 
NBSTATUS VAR Byte 'Status PINK module. 
NBVAR VAR Byte(16) 
NewUDP VAR NBSTATUS.BIT5 'UDP updatebit. 
T2400 CON 396 
DEBUG CLS, "Starting with main module.", CR 
MAIN: 
DEBUG "Main module", CR 
PAUSE 2000 
SEROUT 8,T2400,[noparse][[/noparse]"!NB0ST"] 'Poll the PINK 
SERIN 7,T2400,[noparse][[/noparse]NBSTATUS] 'Read status register 
' DEBUG BIN8 nbstatus 
IF NewUDP = 1 THEN show 'Check UDP bit5 
GOTO MAIN 
END 

' Show the the UDP message. 
show: 
DEBUG "Accessing subroutine SHOW", CR 
PAUSE 300 
SEROUT 8,T2400,[noparse][[/noparse]"!NB0BM"] 
SERIN 7,T2400,[noparse][[/noparse]STR NBVAR\16\CLS] 
DEBUG STR NBVAR 
RETURN


The problem is the SEROUT 8,T2400,[noparse][[/noparse]"!NB0BM"] line. I tried !NB0RBM, !NB0WBM, !NB0BM. In the case of !NB0RBM the program restarts from scratch every time an UDP message is recieved??

Does someone have a solution to this problem?

Reagards,

Marcel

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2006-09-18 16:44
    When newudp=1 you goto show.
    So you must not use return at the end of show,
    but goto main.
    or use

    if newudp = 0 then main
    gosub show
    goto main

    The command to read varBM is !NB0RBM

    regards peter


    Post Edited (Peter Verkaik) : 9/18/2006 4:51:10 PM GMT
  • MarcelMarcel Posts: 32
    edited 2006-09-18 17:20
    Peter,

    Thanks, both·indications·were the solution! Now it works.

    Regards,

    Marcel
Sign In or Register to comment.