Serial Port Stops functioning
jellybean
Posts: 8
I have programed up 2 way coms for my Amplifiers and ever now and then the cease to work.
I have to power down the amplifier to clear the issue. I assumed it was the amplifiers problem, or may be i was sending it some rubish data the locks it once in a while, until i added a port/device and the same thing happens this one.
No this time i'm sending no data, just recieving, it works for a few hours then bombs out. The only recovery that works is a reset of the netlinx processor (NI3000).
Re-uploading the program has no effect. I have put the code below.
Can anyone see where i've errored or is there a fault with my NI3000
[
MODULE_NAME='SKYHD DATA RX'()
DEFINE_DEVICE
SKYHD_RX = 5001:7:0
MODTP = 10001:2:0
MODTP2 = 10004:2:0
DEFINE_VARIABLE
CHAR SKYHDBUFF[2000],STRING_LENGTH_A[500],SKY_CHAN_TEXT[500],SKY_DESC_TEXT[500],
SKY_PROG_TEXT[500],SKY_NUM_TEXT[500],SKY_ACTION_TEXT[500],JUNK[100],JUNK_STRING[100]
INTEGER SSCN_POS,GET_STRING_LENGTH,STRING_LENGTH_I,TEXT_POS,STR_LNGTH,
DUMP,SKYHD_PLAYBACK,SKYHD_PAUSED,SKYHD_FFWD,SKYHD_FREV,SKY_STOP
DEFINE_MUTUALLY_EXCLUSIVE
(SKYHD_FFWD,SKYHD_FREV,SKYHD_PAUSED,SKYHD_PLAYBACK,SKY_STOP)
([MODTP,94],[MODTP,95],[MODTP,97]..[MODTP,99])
DEFINE_CALL 'SKY-NUMBER'
{
SSCN_POS = FIND_STRING(SKYHDBUFF,'SSCN',1)
IF (SSCN_POS >0)
{
GET_STRING_LENGTH=SSCN_POS+4
STRING_LENGTH_A=MID_STRING(SKYHDBUFF,GET_STRING_LENGTH,3)
STRING_LENGTH_I=ATOI( STRING_LENGTH_A)
STR_LNGTH=STRING_LENGTH_I-7
TEXT_POS=SSCN_POS+7
SKY_NUM_TEXT=MID_STRING(SKYHDBUFF,TEXT_POS,STR_LNGTH)
SEND_COMMAND MODTP, "'!T',55,SKY_NUM_TEXT"
SEND_COMMAND MODTP2, "'!T',55,SKY_NUM_TEXT"
JUNK_STRING=MID_STRING(SKYHDBUFF, SSCN_POS,STRING_LENGTH_I)
JUNK=REMOVE_STRING(SKYHDBUFF,JUNK_STRING,1)
}
}
DEFINE_CALL 'SKY-CHANNEL'
{
SSCN_POS = FIND_STRING(SKYHDBUFF,'SSCA',1)
IF (SSCN_POS >0)
{
GET_STRING_LENGTH=SSCN_POS+4
STRING_LENGTH_A=MID_STRING(SKYHDBUFF,GET_STRING_LENGTH,3)
STRING_LENGTH_I=ATOI( STRING_LENGTH_A)
STR_LNGTH=STRING_LENGTH_I-7
TEXT_POS=SSCN_POS+7
SKY_CHAN_TEXT=MID_STRING(SKYHDBUFF,TEXT_POS,STR_LNGTH)
SEND_COMMAND MODTP, "'!T',56,SKY_CHAN_TEXT"
SEND_COMMAND MODTP2, "'!T',56,SKY_CHAN_TEXT"
JUNK_STRING=MID_STRING(SKYHDBUFF, SSCN_POS,STRING_LENGTH_I)
JUNK=REMOVE_STRING(SKYHDBUFF,JUNK_STRING,1)
}
}
DEFINE_CALL 'SKY-PROG'
{
SSCN_POS = FIND_STRING(SKYHDBUFF,'SSN',1)
IF (SSCN_POS >0)
{
GET_STRING_LENGTH=SSCN_POS+4
STRING_LENGTH_A=MID_STRING(SKYHDBUFF,GET_STRING_LENGTH,3)
STRING_LENGTH_I=ATOI( STRING_LENGTH_A)
STR_LNGTH=STRING_LENGTH_I-7
TEXT_POS=SSCN_POS+7
SKY_PROG_TEXT=MID_STRING(SKYHDBUFF,TEXT_POS,STR_LNGTH)
SEND_COMMAND MODTP, "'!T',57,SKY_PROG_TEXT"
SEND_COMMAND MODTP2, "'!T',57,SKY_PROG_TEXT"
JUNK_STRING=MID_STRING(SKYHDBUFF, SSCN_POS,STRING_LENGTH_I)
JUNK=REMOVE_STRING(SKYHDBUFF,JUNK_STRING,1)
}
}
DEFINE_CALL 'SKY-DESCRIPTION'
{
SSCN_POS = FIND_STRING(SKYHDBUFF,'SSE0',1)
IF (SSCN_POS >0)
{
GET_STRING_LENGTH=SSCN_POS+4
STRING_LENGTH_A=MID_STRING(SKYHDBUFF,GET_STRING_LENGTH,3)
STRING_LENGTH_I=ATOI( STRING_LENGTH_A)
STR_LNGTH=STRING_LENGTH_I-7
TEXT_POS=SSCN_POS+7
SKY_DESC_TEXT=MID_STRING(SKYHDBUFF,TEXT_POS,STR_LNGTH)
SEND_COMMAND MODTP, "'!T',58,SKY_DESC_TEXT"
SEND_COMMAND MODTP2, "'!T',58,SKY_DESC_TEXT"
JUNK_STRING=MID_STRING(SKYHDBUFF,SSCN_POS,STRING_LENGTH_I)
JUNK=REMOVE_STRING(SKYHDBUFF,JUNK_STRING,1)
}
}
DEFINE_CALL 'SKY-PLAYBACK'
{
SSCN_POS = FIND_STRING(SKYHDBUFF,'SSEI',1)
IF (SSCN_POS >0)
{
GET_STRING_LENGTH=SSCN_POS+4
STRING_LENGTH_A=MID_STRING(SKYHDBUFF,GET_STRING_LENGTH,3)
STRING_LENGTH_I=ATOI( STRING_LENGTH_A)
STR_LNGTH=STRING_LENGTH_I-7
TEXT_POS=SSCN_POS+7
SKY_ACTION_TEXT=MID_STRING(SKYHDBUFF,TEXT_POS,STR_LNGTH)
SEND_COMMAND MODTP, "'!T',59,SKY_ACTION_TEXT"
SEND_COMMAND MODTP2, "'!T',59,SKY_ACTION_TEXT"
JUNK_STRING=MID_STRING(SKYHDBUFF,SSCN_POS,STRING_LENGTH_I)
JUNK=REMOVE_STRING(SKYHDBUFF,JUNK_STRING,1)
IF(SKY_ACTION_TEXT='Playback')
{ON [SKYHD_PLAYBACK]
SEND_COMMAND MODTP,"'^SHO-200&202.204,0'"
SEND_COMMAND MODTP,"'^SHO-201,1'"}
ELSE IF (SKY_ACTION_TEXT='Fast Forward')
{ON[SKYHD_FFWD]
SEND_COMMAND MODTP,"'^SHO-200.201&203.204,0'"
SEND_COMMAND MODTP,"'^SHO-202,1'"}
ELSE IF (SKY_ACTION_TEXT='Rewind')
{ON[SKYHD_FREV]
SEND_COMMAND MODTP,"'^SHO-200.202&204,0'"
SEND_COMMAND MODTP,"'^SHO-203,1'"}
ELSE IF (SKY_ACTION_TEXT='Pause')
{ON[SKYHD_PAUSED]
SEND_COMMAND MODTP,"'^SHO-200.203,0'"
SEND_COMMAND MODTP,"'^SHO-204,1'"}
}
IF(SSCN_POS =0)
{SKY_STOP=1
SEND_COMMAND MODTP,"'^SHO-200.204,0'"}
}
DEFINE_START
CREATE_BUFFER SKYHD_RX,SKYHDBUFF
DEFINE_EVENT
DATA_EVENT [SKYHD_RX]
{ STRING:
{
SELECT
{
ACTIVE(FIND_STRING(SKYHDBUFF,'SSCN',1)):
{CALL 'SKY-NUMBER'
WAIT 3 'W1' CALL 'SKY-CHANNEL'
WAIT 6 'W2' CALL 'SKY-PROG'
WAIT 9 'W3' CALL 'SKY-DESCRIPTION'
WAIT 11 'W4' CALL 'SKY-PLAYBACK'
WAIT 13 'DUMP' DUMP=1}
}
}
}
DEFINE_PROGRAM
IF (DUMP=1)
{CLEAR_BUFFER SKYHDBUFF
DUMP=0
}
// SEND_COMMAND <DEV>,"'^SHO-<vt addr range>,<command value>'"
//200 BLANK
//201 PLAY
//202 FF
//203 FR
//204 PAUSE
// SEND_COMMAND Panel,"'^SHO-500.504&510.515,0'"
IF(SKYHD_PLAYBACK=1)
{[MODTP,94]=1
}
IF(SKYHD_PAUSED=1)
{[MODTP,98]=1
}
IF(SKYHD_FFWD=1)
{[MODTP,99]=1
}
IF(SKYHD_FREV=1)
{[MODTP,97]=1
}
IF(SKY_STOP=1)
{[MODTP,96]=1
}
]
I have to power down the amplifier to clear the issue. I assumed it was the amplifiers problem, or may be i was sending it some rubish data the locks it once in a while, until i added a port/device and the same thing happens this one.
No this time i'm sending no data, just recieving, it works for a few hours then bombs out. The only recovery that works is a reset of the netlinx processor (NI3000).
Re-uploading the program has no effect. I have put the code below.
Can anyone see where i've errored or is there a fault with my NI3000
[
MODULE_NAME='SKYHD DATA RX'()
DEFINE_DEVICE
SKYHD_RX = 5001:7:0
MODTP = 10001:2:0
MODTP2 = 10004:2:0
DEFINE_VARIABLE
CHAR SKYHDBUFF[2000],STRING_LENGTH_A[500],SKY_CHAN_TEXT[500],SKY_DESC_TEXT[500],
SKY_PROG_TEXT[500],SKY_NUM_TEXT[500],SKY_ACTION_TEXT[500],JUNK[100],JUNK_STRING[100]
INTEGER SSCN_POS,GET_STRING_LENGTH,STRING_LENGTH_I,TEXT_POS,STR_LNGTH,
DUMP,SKYHD_PLAYBACK,SKYHD_PAUSED,SKYHD_FFWD,SKYHD_FREV,SKY_STOP
DEFINE_MUTUALLY_EXCLUSIVE
(SKYHD_FFWD,SKYHD_FREV,SKYHD_PAUSED,SKYHD_PLAYBACK,SKY_STOP)
([MODTP,94],[MODTP,95],[MODTP,97]..[MODTP,99])
DEFINE_CALL 'SKY-NUMBER'
{
SSCN_POS = FIND_STRING(SKYHDBUFF,'SSCN',1)
IF (SSCN_POS >0)
{
GET_STRING_LENGTH=SSCN_POS+4
STRING_LENGTH_A=MID_STRING(SKYHDBUFF,GET_STRING_LENGTH,3)
STRING_LENGTH_I=ATOI( STRING_LENGTH_A)
STR_LNGTH=STRING_LENGTH_I-7
TEXT_POS=SSCN_POS+7
SKY_NUM_TEXT=MID_STRING(SKYHDBUFF,TEXT_POS,STR_LNGTH)
SEND_COMMAND MODTP, "'!T',55,SKY_NUM_TEXT"
SEND_COMMAND MODTP2, "'!T',55,SKY_NUM_TEXT"
JUNK_STRING=MID_STRING(SKYHDBUFF, SSCN_POS,STRING_LENGTH_I)
JUNK=REMOVE_STRING(SKYHDBUFF,JUNK_STRING,1)
}
}
DEFINE_CALL 'SKY-CHANNEL'
{
SSCN_POS = FIND_STRING(SKYHDBUFF,'SSCA',1)
IF (SSCN_POS >0)
{
GET_STRING_LENGTH=SSCN_POS+4
STRING_LENGTH_A=MID_STRING(SKYHDBUFF,GET_STRING_LENGTH,3)
STRING_LENGTH_I=ATOI( STRING_LENGTH_A)
STR_LNGTH=STRING_LENGTH_I-7
TEXT_POS=SSCN_POS+7
SKY_CHAN_TEXT=MID_STRING(SKYHDBUFF,TEXT_POS,STR_LNGTH)
SEND_COMMAND MODTP, "'!T',56,SKY_CHAN_TEXT"
SEND_COMMAND MODTP2, "'!T',56,SKY_CHAN_TEXT"
JUNK_STRING=MID_STRING(SKYHDBUFF, SSCN_POS,STRING_LENGTH_I)
JUNK=REMOVE_STRING(SKYHDBUFF,JUNK_STRING,1)
}
}
DEFINE_CALL 'SKY-PROG'
{
SSCN_POS = FIND_STRING(SKYHDBUFF,'SSN',1)
IF (SSCN_POS >0)
{
GET_STRING_LENGTH=SSCN_POS+4
STRING_LENGTH_A=MID_STRING(SKYHDBUFF,GET_STRING_LENGTH,3)
STRING_LENGTH_I=ATOI( STRING_LENGTH_A)
STR_LNGTH=STRING_LENGTH_I-7
TEXT_POS=SSCN_POS+7
SKY_PROG_TEXT=MID_STRING(SKYHDBUFF,TEXT_POS,STR_LNGTH)
SEND_COMMAND MODTP, "'!T',57,SKY_PROG_TEXT"
SEND_COMMAND MODTP2, "'!T',57,SKY_PROG_TEXT"
JUNK_STRING=MID_STRING(SKYHDBUFF, SSCN_POS,STRING_LENGTH_I)
JUNK=REMOVE_STRING(SKYHDBUFF,JUNK_STRING,1)
}
}
DEFINE_CALL 'SKY-DESCRIPTION'
{
SSCN_POS = FIND_STRING(SKYHDBUFF,'SSE0',1)
IF (SSCN_POS >0)
{
GET_STRING_LENGTH=SSCN_POS+4
STRING_LENGTH_A=MID_STRING(SKYHDBUFF,GET_STRING_LENGTH,3)
STRING_LENGTH_I=ATOI( STRING_LENGTH_A)
STR_LNGTH=STRING_LENGTH_I-7
TEXT_POS=SSCN_POS+7
SKY_DESC_TEXT=MID_STRING(SKYHDBUFF,TEXT_POS,STR_LNGTH)
SEND_COMMAND MODTP, "'!T',58,SKY_DESC_TEXT"
SEND_COMMAND MODTP2, "'!T',58,SKY_DESC_TEXT"
JUNK_STRING=MID_STRING(SKYHDBUFF,SSCN_POS,STRING_LENGTH_I)
JUNK=REMOVE_STRING(SKYHDBUFF,JUNK_STRING,1)
}
}
DEFINE_CALL 'SKY-PLAYBACK'
{
SSCN_POS = FIND_STRING(SKYHDBUFF,'SSEI',1)
IF (SSCN_POS >0)
{
GET_STRING_LENGTH=SSCN_POS+4
STRING_LENGTH_A=MID_STRING(SKYHDBUFF,GET_STRING_LENGTH,3)
STRING_LENGTH_I=ATOI( STRING_LENGTH_A)
STR_LNGTH=STRING_LENGTH_I-7
TEXT_POS=SSCN_POS+7
SKY_ACTION_TEXT=MID_STRING(SKYHDBUFF,TEXT_POS,STR_LNGTH)
SEND_COMMAND MODTP, "'!T',59,SKY_ACTION_TEXT"
SEND_COMMAND MODTP2, "'!T',59,SKY_ACTION_TEXT"
JUNK_STRING=MID_STRING(SKYHDBUFF,SSCN_POS,STRING_LENGTH_I)
JUNK=REMOVE_STRING(SKYHDBUFF,JUNK_STRING,1)
IF(SKY_ACTION_TEXT='Playback')
{ON [SKYHD_PLAYBACK]
SEND_COMMAND MODTP,"'^SHO-200&202.204,0'"
SEND_COMMAND MODTP,"'^SHO-201,1'"}
ELSE IF (SKY_ACTION_TEXT='Fast Forward')
{ON[SKYHD_FFWD]
SEND_COMMAND MODTP,"'^SHO-200.201&203.204,0'"
SEND_COMMAND MODTP,"'^SHO-202,1'"}
ELSE IF (SKY_ACTION_TEXT='Rewind')
{ON[SKYHD_FREV]
SEND_COMMAND MODTP,"'^SHO-200.202&204,0'"
SEND_COMMAND MODTP,"'^SHO-203,1'"}
ELSE IF (SKY_ACTION_TEXT='Pause')
{ON[SKYHD_PAUSED]
SEND_COMMAND MODTP,"'^SHO-200.203,0'"
SEND_COMMAND MODTP,"'^SHO-204,1'"}
}
IF(SSCN_POS =0)
{SKY_STOP=1
SEND_COMMAND MODTP,"'^SHO-200.204,0'"}
}
DEFINE_START
CREATE_BUFFER SKYHD_RX,SKYHDBUFF
DEFINE_EVENT
DATA_EVENT [SKYHD_RX]
{ STRING:
{
SELECT
{
ACTIVE(FIND_STRING(SKYHDBUFF,'SSCN',1)):
{CALL 'SKY-NUMBER'
WAIT 3 'W1' CALL 'SKY-CHANNEL'
WAIT 6 'W2' CALL 'SKY-PROG'
WAIT 9 'W3' CALL 'SKY-DESCRIPTION'
WAIT 11 'W4' CALL 'SKY-PLAYBACK'
WAIT 13 'DUMP' DUMP=1}
}
}
}
DEFINE_PROGRAM
IF (DUMP=1)
{CLEAR_BUFFER SKYHDBUFF
DUMP=0
}
// SEND_COMMAND <DEV>,"'^SHO-<vt addr range>,<command value>'"
//200 BLANK
//201 PLAY
//202 FF
//203 FR
//204 PAUSE
// SEND_COMMAND Panel,"'^SHO-500.504&510.515,0'"
IF(SKYHD_PLAYBACK=1)
{[MODTP,94]=1
}
IF(SKYHD_PAUSED=1)
{[MODTP,98]=1
}
IF(SKYHD_FFWD=1)
{[MODTP,99]=1
}
IF(SKYHD_FREV=1)
{[MODTP,97]=1
}
IF(SKY_STOP=1)
{[MODTP,96]=1
}
]
0
Comments
ok code brackets???
and what does :P mean
Cheers
Have attached code
Try this
one other thing, is your Netlinx controller still receiving data? Does the RX Led blink?