glcddrivers: fixed input handling
authorcpresser@rika
Thu, 07 Feb 2008 12:41:15 +0000
changeset 2023b8c749e5a0
parent 19 ad1139d9e73f
child 21 f1573dd6dace
glcddrivers: fixed input handling
graphlcd-base/glcddrivers/picctl.c
     1.1 --- a/graphlcd-base/glcddrivers/picctl.c	Thu Feb 07 12:20:47 2008 +0000
     1.2 +++ b/graphlcd-base/glcddrivers/picctl.c	Thu Feb 07 12:41:15 2008 +0000
     1.3 @@ -104,7 +104,7 @@
     1.4  
     1.5  void cDriverPICCtl::SignalHandler(int signal)
     1.6  {
     1.7 -//    uint8_t i;
     1.8 +    //uint8_t i;
     1.9  
    1.10      // read all available data
    1.11      while (instance->port->ReadData(&buf[buf_pos]) > 0)
    1.12 @@ -114,6 +114,13 @@
    1.13  	{
    1.14  	    if (buf_cmd_start != 255)
    1.15  	    {
    1.16 +		/*printf("Damaged Packet: ");
    1.17 +	        for (i=buf_cmd_start; i<buf_pos; i++)
    1.18 +		{
    1.19 +		  printf("0x%02x ",buf[i]);
    1.20 +		}
    1.21 +		printf("; buf_pos = %d, buf_cmd_start = %d\n",buf_pos,buf_cmd_start);*/
    1.22 +
    1.23                  syslog(LOG_INFO, "PICCtl received a malformed packet. Scrapped %d bytes\n",(buf_pos - buf_cmd_start));
    1.24  		buf_pos = 0;
    1.25  		buf[buf_pos] = CMD_SYNC_RECV;
    1.26 @@ -137,10 +144,10 @@
    1.27  	buf_pos++;
    1.28  
    1.29          // we need to check for a valid packet...
    1.30 -	if (buf_pos >= CMD_DATA_START)
    1.31 +	if ((buf_pos - buf_cmd_start) >= CMD_DATA_START)
    1.32  	{
    1.33              // if we recieved a valid packet: start decoding
    1.34 -	    if (buf[CMD_HDR_LENGTH+1] == (buf_pos - CMD_DATA_START))
    1.35 +	    if (buf[buf_cmd_start + CMD_HDR_LENGTH+1] == (buf_pos - buf_cmd_start - CMD_DATA_START))
    1.36  	    {
    1.37  	        instance->DecodeCmd(&buf[buf_cmd_start],buf_pos);
    1.38  		buf_pos = 0;
    1.39 @@ -165,6 +172,7 @@
    1.40  	 			break;
    1.41  
    1.42  	case CMD_SYS_IR:	syslog(LOG_INFO," %s: incoming Key-Event 0x%02x (Source 0x%02x)\n",config->name.c_str(), cmd[CMD_DATA_START+1], cmd[CMD_DATA_START]);
    1.43 +	                        printf(" %s: incoming Key-Event 0x%02x (Source 0x%02x)\n",config->name.c_str(), cmd[CMD_DATA_START+1], cmd[CMD_DATA_START]);
    1.44  	  			break;
    1.45  
    1.46  	default:		syslog(LOG_INFO," %s: recieved Message 0x%x \n",config->name.c_str(), cmd[CMD_HDR_COMMAND]);