Shop OBEX P1 Docs P2 Docs Learn Events
BS2 + EB500/EB501 = Err 3 — Parallax Forums

BS2 + EB500/EB501 = Err 3

ObsoleteSuperManObsoleteSuperMan Posts: 12
edited 2007-05-04 13:48 in BASIC Stamp
every now and again, my eb500 starts sending error 3 messages. was'nt sure why it was doing this so when it errors i just reset the stamp until it starts working properly again. and after a random amount of time, it stops working, another reason i make it reset every few executions. below is my code. any of you eb500 veterans that can take a look, i woulde appreciate it.

' {$STAMP BS2}
' {$PBASIC 2.5}
' BLUE TOOTH DEVICES AS ACCESS CONTROL KEYFOBS
' ALLOW ENTRY AND HOUSE\BUSINESS SCENE BY BLUETOOTH ENABLED DEVICES
'---------------------[noparse][[/noparse] Variables ]--------------------------
bErrorCode      VAR     Byte
Buffer          VAR     Byte(17)                ' bytes buffer
Check           VAR     Byte
Char            VAR     Byte                    ' character to test
tagNum          VAR     Nib                     ' from EEPROM table
idx             VAR     Byte                    ' byte index
MACidx          VAR     Byte                    ' byte index
'---------------------[noparse][[/noparse] Constants ]--------------------------
 SerialPort CON 16
 Baud   CON 84+$4000
'---------------------[noparse][[/noparse] Data Storage ]--------------------------
'Below are the authorized addresses that are allowed entry
DATA    "00:17:00:04:1F:21" ' Clark Ober
DATA    "00:12:D2:15:94:3D" ' Chris Gagner
DATA    "00:18:A4:B2:EF:5F" ' Bryan Quintana
DATA    "00:12:D2:CB:2A:1A" ' Kerry Brandon
DATA    "00:12:D1:58:FA:87" ' Scott Matson
DATA    "00:12:D1:61:86:A1" ' Ben Cope

Setup:
'set connectable off
'SEROUT 1,84,[noparse][[/noparse]"set connectable on",CR]
'SERIN 0,84,[noparse][[/noparse]WAIT("ACK",CR)]
'SEROUT SerialPort,Baud,[noparse][[/noparse]"Set connectable OFF!",CR]
'set connectable off
'SEROUT 1,84,[noparse][[/noparse]"set visible on",CR]
'SERIN 0,84,[noparse][[/noparse]WAIT("ACK",CR)]
'SEROUT SerialPort,Baud,[noparse][[/noparse]"Set visible OFF!",CR]
'set name
'SEROUT 1,84,[noparse][[/noparse]"set name DOORSTOP",CR]
'SERIN 0,84,[noparse][[/noparse]WAIT("ACK",CR)]
'SEROUT SerialPort,Baud,[noparse][[/noparse]"Set Name to DOORSTOP!",CR]
'set security closed
'SEROUT 1,84,[noparse][[/noparse]"set security closed",CR]
'SERIN 0,84,[noparse][[/noparse]WAIT("ACK",CR)]
'SEROUT SerialPort,Baud,[noparse][[/noparse]"Set Security CLOSED!",CR]
'set transmit power
SEROUT 1,84,[noparse][[/noparse]"set txpower 1",CR]
SERIN 0,84,[noparse][[/noparse]WAIT("ACK",CR)]
'SERIN 0,84,[noparse][[/noparse]WAIT("1",CR)]
SEROUT SerialPort,Baud,[noparse][[/noparse]"Set txpower 1",CR]
'PAUSE 1000
INPUT 9                           'make pin that resets BS2 to input so it has no voltage
'FOR Reset = 0 TO 3
 'IF Reset = 3 THEN GetOFF
GetVisible:
'get visable id's and send them to the serialport
HIGH 8
SEROUT 1,84,[noparse][[/noparse]"lst visible 5",CR]
'SEROUT serialport,baud,[noparse][[/noparse]"List Visible...",CR]
SERIN 0,84,[noparse][[/noparse]WAIT("ACK",CR)]
'SEROUT serialport,baud,[noparse][[/noparse]"ACK",CR]
GetList:
'Buffer eb500 response
SERIN 0,84,[noparse][[/noparse]STR Buffer\17\">"]
'SEROUT serialport,baud,[noparse][[/noparse]"Start data buffer...",CR]
SEROUT SerialPort,Baud,[noparse][[/noparse]STR Buffer,CR]
PAUSE 500
' poppin fresh checks
IF Buffer(0) = "E" THEN ErrorCode                         'Watch for Error codes
IF Buffer(0) = 0 THEN GetVisible                       'Watch for end of list VIA blank buffer
'loop to check the buffered address against the Authorized list
   FOR MACidx = 0 TO 6 '<--- change number to number of Authorized MACs in EEPROM
     Check = 0
       FOR idx = 0 TO 16                            ' scan bytes in tag
         READ MACidx * 17 + idx, Char
         IF Buffer(idx) = Char THEN Check = Check + 1
         SEROUT serialport,baud,[noparse][[/noparse]Char]
       NEXT
     SEROUT SerialPort, Baud, [noparse][[/noparse]"  - Check chars = ", Check,CR]
     PAUSE 500
     IF Check = 17 THEN AccessGranted
   NEXT
'LOW 9
GOTO GetList
AccessGranted:
'SEROUT SerialPort,Baud,[noparse][[/noparse]"Should I let them in?",CR]
LOW 8
HIGH 7
PAUSE 5000
LOW 7
HIGH 8
Check = 0
RETURN
'ConnectToBuffered:
'SEROUT 1,84,[noparse][[/noparse]"con ",STR bBuffer,CR]
'SERIN 0,84,[noparse][[/noparse]WAIT("ACK",CR)]
'SEROUT serialport,baud,[noparse][[/noparse]"Connecting to ",STR bBuffer,CR]
'WaitForConnection:
'SEROUT serialport,baud,[noparse][[/noparse]"Waiting for Connection...",CR]
' IF IN5=0 THEN WaitForConnection
'SEROUT serialport,baud,[noparse][[/noparse]"Connection Established! HURRAY!",CR]

'Error Handling
ErrorCode:
        bErrorCode = Buffer(4)
        DEBUG "Error: ",STR bErrorCode,CR
        LOW 9
        END

i want to perfect my code before starting to make the hardware smaller.
Sign In or Register to comment.