SE955 雷射掃瞄頭設定 通過SSI串列埠進行設定

2021-09-07 11:43:35 字數 2340 閱讀 1278

掃瞄頭是能夠進行配置的,使其支援與禁用某些條碼型別,設定有兩種方式,一種是掃一下相應的設定條碼,還有一種是通過ssi(****** serial inte***ce)來設定,以下就講一下ssi的設定方式。

掃瞄頭在上電以後,就能夠對其傳送相應引數設定了,摩托羅拉建議設定暫時引數。設定永久生效的引數會損害掃瞄頭內部的flash,flash損壞後掃瞄頭將無法使用,比方出現乙個點的雷射,正常情況是一條線。flash壽命有限,請謹慎。暫時設定會在掃瞄頭斷電以後丟失。每次上電的時候都要設定一次,所以建議將須要設定的引數寫入到登錄檔中。每次上電以後從登錄檔讀取。

static char wakeup					=			;

//2's complement sum of message contents excluding checksum.

static size_t __checksum(char data,size_t d_size)

while(d_size--)

return ((~sum)+1);

}//store params to register,when power off

int setscannersetvaluetolocal(void *data,size_t len)

;    size_t iretval=0;

assert(data!=null && len>0);

if(error_success == regopenkeyex(hkey_local_machine,_t("hardware\\scandev\\setting"),0,0,&hk))

else

}else

else

}regclosekey(hk);

return iretval;

#endif

}static void __getscannersetvaluefromlocal(void *data,size_t in_len,size_t * out_len)

; if(error_success == regopenkeyex(hkey_local_machine,_t("hardware\\scandev\\setting"),0,0,&hk))

else

}} regclosekey(hk);

#endif /*end of macro wince*/

}//when scanner engine power on,you can call this function

static size_t setparamvalues(void)

; size_t count=0;

size_t len=0,i=0;

char buffer[4096]=;

//attention!!! temporary change - lost when power removed

//failure to meet these conditions can corrupt the scan engine's memory.

//must be 0x00,0xff,not is 0x01,0xff

char temp=;

__getscannersetvaluefromlocal(param_list,sizeof(param_list),&count);

if(param_list == null || count <= 0)

len=sizeof(temp)/sizeof(char);

buffer[0]=((count+len+1)&0xff); //length

memcpy(buffer+1,temp,len);

memcpy(buffer+len+1,param_list,count);

check_sum=__checksum(buffer,len+count+1);

buffer[len+count+1]=((check_sum>>8)&0xff); //height byte

buffer[len+count+2]=(check_sum&0xff); //low byte

write_com_data(wakeup,sizeof(wakeup));

_sleep(100); //change from 70 to 100ms waiting for scanner wakeup

write_com_data(buffer,len+count+3); //length: 1 byte,checksum: 2 byte

return 0;

#endif /*end of macro wince*/

}

write_com_data的api是平台相關性的,請依據自身平台不同改動實現。