DATA1 : KEYPAD_UP = 0x30, KEYPAD_DOWN = 0x31
DATA2 : KEY_A = 30, KEY_B = 48, KEY_C = 46, KEY_D = 32, KEY_E = 18, KEY_F = 33, KEY_G = 34,
KEY_H = 35, KEY_I = 23, KEY_J = 36, KEY_K = 37, KEY_L = 38, KEY_M = 50, KEY_N = 49,
KEY_O = 24, KEY_P = 25, KEY_F1 = 59, KEY_F2 = 60, KEY_F10 = 68, KEY_F11 = 87
DATA3 : DATA_RESERVED = 0x20
/*
* Function name : OperThread
* Description : This function is a parsing packets in ring buffer.
*/
void Serial_Daemon::OperThread()
{
int ptr_start, ptr_end;
unsigned int crc_buf;
/* check STX and ETX in packet */
m_abyBuffer.FindChar(STX,ptr_start);
m_abyBuffer.FindChar(ETX,ptr_end);
if((ptr_start >= ptr_end) && (ptr_end - ptr_start != 8)){
return;
}
…
중략
…
/* Pasing packet */
if(g_Packet_Buffer[1] != MOD_GET){
return;
}
if(g_Packet_Buffer[2] != SEL_KEYPAD){
return;
}
crc_buf = crc16_append(g_Packet_Buffer,6);
if((g_Packet_Buffer[6] !=(char)((crc_buf>>8)&0xff)) ||
(g_Packet_Buffer[7]!=(char)(crc_buf&0xff))){ //CRC Check
return;
}
if(g_Packet_Buffer[3] == KEYPAD_DOWN){
Keydown_Event(g_Packet_Buffer);
}
if(g_Packet_Buffer[3] == KEYPAD_UP){
Keyup_Event(g_Packet_Buffer);
}
}
/*
* Function name : Keydown_Event
* Description : This functin is keydown event.
* If you want to output consecutive key values, add a sync event.
*/
void Serial_Daemon::Keydown_Event(char key_down[10])
{
struct input_event event;
char Receive_Packetf[10] = {0, };
strcpy(Receive_Packetf,key_down);
//Input key event
memset(&event,0,sizeof(event));
event.type = EV_KEY;
event.code = Receive_Packetf[4];