Shop OBEX P1 Docs P2 Docs Learn Events
BS2 serial string truncated — Parallax Forums

BS2 serial string truncated

tabbotttabbott Posts: 26
edited 2007-09-06 15:06 in BASIC Stamp
I use the BS2 to collect data from our tools·and send to a·PLC. There has been some complaints of the data string occasionally missing·the last entry. Connecting a tee to the serial line and observing the sent data on a laptop confirms this issue. About one in a 100 lines has the dropped data. It's puzzling me because the last 3 entries are·all sent in the same command. Devices used at different locations have the same problem.

So we will see something like this on both devices monitoring the serial data:

112761······· 65.0····· 348······ 21221
112762······· 65.2····· 351······ 21221
112763······· 65.3····· 353······ 21221
112764······· 65.2····· 351······ 21221
112765······· 65.2····· 351······ 21221
112766······· 65.1····· 350······ 21221
112767······· 65.2····· 351······
112768······· 65.2····· 351······ 21221
112769······· 65.2····· 351······ 21221
112770······· 65.4····· 355······ 21221
112761······· 65.2····· 351······ 21221

Attached is the full code, but this segment is the issue:

IF UpperCount=0 THEN Skip6·······
SEROUT 16,16780,[noparse][[/noparse]DEC UpperCount,DEC4 ClampCount,9]
GOTO Skip7
Skip6:·············
SEROUT 16,16780,[noparse][[/noparse]DEC ClampCount,9]
Skip7:·············
SEROUT 16,16780,[noparse][[/noparse]DEC Result/10,".",DEC Result//10,9,DEC Force,9,DEC SerialNumber,9]
...
SEROUT 16,16780,[noparse][[/noparse]10,13]

Any ideas as to the cause and/or a fix?
·····

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2007-09-06 00:13
    If "SerialNumber" is set to zero, you'd see this. Are you re-using the "SerialNumber" variable for anything?

    Edit:· Yup, review shows, at line 268 if "tempSerial" is zero, you call "SetYellow".· One side effect of "SetYellow" is to set SerialNumber to the (holding zero) "tempSerial".

    Post Edited (allanlane5) : 9/6/2007 12:25:11 AM GMT
  • tabbotttabbott Posts: 26
    edited 2007-09-06 15:06
    Except that when the program enters SetYellow with tempserial set to zero, it will never leave the loop until it reads something other than 0 or 65535.
    And I belive I would see the number 0 instead of a blank - I am using the DEC modifier.

    SetYellow: 'place the box in a "new tool" mode (tool has been disconnected)
    HIGH YellowLED
    LOW GreenLED
    NewTool = 1
    SerialNumber = tempserial
    PAUSE 10
    GOTO CheckTool
Sign In or Register to comment.