Shop OBEX P1 Docs P2 Docs Learn Events
Sending and String Variable to the PINK module — Parallax Forums

Sending and String Variable to the PINK module

Robert CrouchRobert Crouch Posts: 2
edited 2009-07-25 02:50 in BASIC Stamp
Hello All,·
I am using a BS2P4 with the Pink module and am wanting to send UDP messages of a string of·variables to·an awaiting syslog server.
·
The issue I have is "how do I fill in the line SEROUT TX, Baud, [noparse][[/noparse]"!NB0WBM:MachineID,[noparse][[/noparse]spd1var],;", CLS]· with my varialbles that I have defined"? I have attached the code that I have so far.
The string that my syslog server is looking for is "MachineID,var,var,;". I do not have the MachineID defined, cause I will just hard code that into the string, if possible.

I am using this to get·run time data and submitting it to a Access database. ··

Comments

  • Robert CrouchRobert Crouch Posts: 2
    edited 2009-07-25 02:50
    Well, I figured it out.
    Not sure if this was the best use of code, but it works.

    Thanks
     
    ' {$STAMP BS2p}
    ' {$PBASIC 2.5}
     
    
    ' -----[noparse][[/noparse] I/O Definitions ]-------------------------------------------------
    RX              PIN     14              ' Serial Receieve Pin --> PINK.TX
    TX              PIN     15              ' Serial Transmit Pin --> PINK.RX
    SPD1            PIN     1               ' Speed 1 Active Input
    AUTO            PIN     6               ' Automaic Mode Active
    COMP            PIN     7               ' Program Complete
    ' -----[noparse][[/noparse] Constants ]-------------------------------------------------------
    Baud            CON     240             ' 9600 bps (BS2p)
    ' -----[noparse][[/noparse] Variables ]-------------------------------------------------------
    nbvar           VAR     Word            ' PINK Data Variable
    spd1var         VAR     Word            ' Speed 1 Variable FOR time COUNT
    trtvar          VAR     Word            ' trtvar Variable for TotalRunTime COUNT
    ' -----[noparse][[/noparse] Program Code ]----------------------------------------------------
    Start:
    trtvar = 0
    spd1var = 0
    Main:
    PAUSE 1000
      INPUT AUTO             'Read pin 1 to see if in Auto Mode or Run (Pin 6)
      IF (AUTO = 1) THEN
      trtvar = trtvar + 1    'Increment Total Run Time value
        INPUT SPD1           'Read if High speed value is used (High=1 or Low=0) (Pin 1)
        IF (SPD1=1) THEN
        spd1var = spd1var + 1       'Increment High speed time value
        ELSE
        ENDIF
        DEBUG DEC trtvar, CR        'Show that the values are incrementing, Testing only
        DEBUG DEC spd1var, CR       'Show that the values are incrementing, Testing only
      ELSE
        GOTO Main                   'Goto Main without incrementing trtvar
      ENDIF
                                    'If program is complete submit data srting
      INPUT COMP
      IF (COMP=1) THEN
      GOTO Submit
      ELSE
      GOTO Main
      ENDIF
     
    Submit:
      SEROUT TX, Baud, [noparse][[/noparse]"!NB0WBI:10.119.3.8", CLS]      'UDP IP address of syslog server
      SEROUT TX, Baud, [noparse][[/noparse]"!NB0WBM:"]
      SEROUT TX, Baud, [noparse][[/noparse]"MachineID,"]                   'UDP message sent to syslog server
      SEROUT TX, Baud, [noparse][[/noparse] DEC trtvar]
      SEROUT TX, Baud, [noparse][[/noparse]","]
      SEROUT TX, Baud, [noparse][[/noparse] DEC spd1var]
      SEROUT TX, Baud, [noparse][[/noparse]",;",CLS]
      SEROUT TX, Baud, [noparse][[/noparse]"!NB0WBP:10000", CLS]           'UDP port of syslog server
      SEROUT TX, Baud, [noparse][[/noparse]"!NB0SB"]                       'Send UDP Message
    




    Post Edited (Robert Crouch) : 7/25/2009 2:56:45 AM GMT
Sign In or Register to comment.