** Enter Setup
Write EEPROM
The scanner has 512 bytes of EEPROM. The EEPROM write command is used to write data to up to 256
addresses. You need to enable EEPROM write before a write operation and recommendedly disable it
afterwards to prevent miswriting. Note that writing without enabling it first will not return any error
message. So it is recommended to implement EEPROM read operation after every write for verification.
Syntax: {Prefix1} {Types} {Lens} {Address} {Datas} {FCS}
Prefix1 : 0x7E 0x00
Types
: 0x04
Lens
: 0x00~0xFF, byte count of Datas. When Lens=0x00, 256 bytes are to be written.
Address : 0x0000~0xFFFF, starting address to write data to.
Datas
: 0x00~0xFF, data to be written into the EEPROM
FCS
: CRC-CCITT checksum (2 bytes).
Computation sequence: Types+ Lens+Address+Datas;
polynomial: X
The following C language program is provided for reference.
unsigned int crc_cal_by_bit(unsigned char* ptr, unsigned int len)
{
unsigned int crc = 0;
while(len-- != 0)
{
for(unsigned char i = 0x80; i != 0; i /= 2)
{
crc *= 2;
if((crc&0x10000) !=0)
crc ^= 0x11021;
if((*ptr&i) != 0)
crc ^= 0x1021;
}
ptr++;
}
return crc;
}
Exit Setup
16
12
5
+X
+X
+1 (0x1021), initial value: 0x0000.
20