Board Programmable Batch Feature (Offline Auto Execution)
Store a batch of CAN/RS485 commands on the board and execute them automatically with configured period and repeat count.
For quick integration, use SANPO Studio to debug, store, and configure auto execution.
All
AT+commands must end with\r\n.This feature is available on firmware
V4.2and later.Send
AT+VER(end with \r\n) to check firmware version; ifV42is not reported, update to the latest firmware.
Command Overview
Command |
Description |
|---|---|
|
Create/overwrite a batch and begin upload |
|
Add one command item (short payload) |
|
Add one chunk for long payload |
|
Finish chunk upload and verify |
|
Commit and persist batch |
|
Run batch ( |
|
Stop current execution |
|
Query batch list |
|
Read batch entry; |
|
Delete a batch |
|
Query runtime status |
|
Configure boot auto-run |
|
Clear boot auto-run configuration |
|
Query boot auto-run configuration |
|
Erase full BATCH storage area (do not use frequently) |
Global Communication Parameters (Persistent)
For offline batch execution, set global CAN/RS485 parameters first:
AT+SETCAN=<baud>: set global CAN baudrate (applies to CAN channels on current board).AT+SETRS485=<baud>,<stop>,<parity>,<bits>: set global RS485 parameters (applies to RS485 channels on current board).
Field definitions:
baud: baudrate (examples: CAN1000000/500000/250000/125000, RS4854000000)stop: stop bits,1or2parity: parity,0=None,1=Odd,2=Evenbits: data bits,8or9
Persistence rule:
After power cycle, the board reloads and applies the last saved parameters automatically.
Example:
AT+SETCAN=1000000
AT+SETRS485=4000000,1,0,8
Field Definitions
id: batch ID, range1..99name: batch name (letters/numbers/underscore/hyphen), max16charsidx: command index in batch, starts from1, must be strictly contiguousproto:1=CAN_STD,2=CAN_EXT,3=RS485ch: channel1..4(0means broadcast)delay_ms: relative delay between commands, range0..9999mshex_payload/hex_part: hexadecimal text (2 chars = 1 byte)mode:1=ONCE,2=PERIODICrepeat: repeat count,0means infinite loopseq: chunk sequence, starts from1off: chunk byte offset, starts from0
Payload Encoding
payloaduses hex text encoding (2 chars = 1 byte)proto=1 (CAN_STD):CANID(2B) + DLC(1B) + DATA(0~8B), total3~11Bproto=2 (CAN_EXT):CANID(4B) + DLC(1B) + DATA(0~8B), total5~13Bproto=3 (RS485): useAT+BATADDfor<=17B; useAT+BATADDXfor longer dataExample (CAN_EXT):
00000123081122334455667788Example (RS485):
A55A010203040506
Length and Chunking Rules
AT+BATADDis for short payload (<=17bytes).For longer payload, use
AT+BATADDX + AT+BATADDEND.
Usage Examples
Create a batch
AT+BATBEGIN=1,walk_cycle
Add one CAN_EXT item
AT+BATADD=1,1,2,1,20,00000123081122334455667788
Add one RS485 item
AT+BATADD=1,2,3,2,10,A55A010203040506
Commit and run (100 ms period, infinite loop)
AT+BATCOMMIT=1
AT+BATRUN=1,2,100,0
Stop
AT+BATSTOP
Chunked example (40-byte RS485)
AT+BATADDX=2,1,3,2,20,40,1,0,11223344556677889900AABBCCDDEEFF
AT+BATADDX=2,1,3,2,20,40,2,16,0102030405060708090A0B0C0D0E0F10
AT+BATADDX=2,1,3,2,20,40,3,32,1112131415161718
AT+BATADDEND=2,1,7A3C
AT+BATCOMMIT=2
Query stored batches
AT+BATLIST?
Response examples:
BATLIST:1,walk_cycle;2,test_rs485
BATLIST:NONE
Read back stored entries
AT+BATREAD=1,0
AT+BATREAD=1,1
AT+BATREAD=1,2
Response format:
BATREAD:id=<id>,name=<name>,count=<count>
BATREAD:id=<id>,idx=<idx>,proto=<proto>,ch=<ch>,delay_ms=<delay_ms>,payload=<hex_payload>
Query status
AT+BATSTAT?
Delete batch
AT+BATDEL=1
Configure boot auto-run
AT+BATAUTOSET=1,2,200,2
AT+BATAUTOSET=1,1,0,0
AT+BATAUTO?
AT+BATAUTOCLR
Erase full BATCH storage
AT+BATERASE
Error Codes
Failure return format:
ERR,<code>
Definitions:
0: success (usually returnsOK)1:BAT_ERR_PARAM, invalid format/missing args/illegal characters2:BAT_ERR_STATE, invalid state (BATADDbeforeBATBEGIN, wrong chunk order, non-contiguousidx)3:BAT_ERR_RANGE, out-of-range params (id/idx/seq/delay_ms/length)4:BAT_ERR_CRC,BATADDENDCRC mismatch5:BAT_ERR_NOSPACE, insufficient flash space6:BAT_ERR_NOTFOUND, batch not found/deleted7:BAT_ERR_QUEUE, send queue busy (retry later)8:BAT_ERR_FLASH, flash read/write/erase failure