# HG changeset patch # User cpresser@rika # Date 1202345143 0 # Node ID ccaf76b245ec8a981453e412b2c7bc3b22c49284 # Parent 9798f65f2f354a4d97024be43c2c65b6237b6c4a made port non-blocking, added debug-code diff -r 9798f65f2f35 -r ccaf76b245ec graphlcd-base/glcddrivers/picctl.c --- a/graphlcd-base/glcddrivers/picctl.c Thu Feb 07 00:18:02 2008 +0000 +++ b/graphlcd-base/glcddrivers/picctl.c Thu Feb 07 00:45:43 2008 +0000 @@ -104,6 +104,8 @@ void cDriverPICCtl::SignalHandler(int signal) { + uint8_t i; + // read all available data while (instance->port->ReadData(&buf[buf_pos])) { @@ -124,15 +126,15 @@ if ((buf[buf_pos] == CMD_ESCAPE_BYTE) && (!buf_flag_escape)) { + // this byte was for masking only.. ignore it! buf_flag_escape = true; - buf_pos--; // should do!!! better would be something like next(); - // set flag... - // next; + continue; } - else - { - buf_flag_escape = false; - } + buf_flag_escape = false; + +/* printf("buf: "); + for (i=1; i<=buf_pos; i++) { printf("0x%02x ",buf[i]);} + printf("\n");*/ // we need to check for a valid packet... if (buf_pos >=CMD_DATA_START) @@ -140,13 +142,14 @@ // if we recieved a valid packet: start decoding if (buf[CMD_HDR_LENGTH+1] == (buf_pos - CMD_DATA_START)) { - instance->DecodeCmd(&buf[buf_cmd_start],(buf_pos-1)); + instance->DecodeCmd(&buf[buf_cmd_start],(buf_pos)); buf_pos = 0; buf_cmd_start = 0; } } buf_pos++; + printf ("still captured in while-loop\n"); } } @@ -154,9 +157,16 @@ void cDriverPICCtl::DecodeCmd(uint8_t * cmd, uint8_t len) { + uint8_t i; + + printf("cmd(%2d): ",len); + for (i=0; iack_flag = true; + case CMD_SYS_ACK: ack_flag = true; + printf ("ack_!\n"); break; case CMD_SYS_IR: printf(" Incoming Key-Event 0x%02x (Source 0x%02x)\n",cmd[CMD_DATA_START+1],cmd[CMD_DATA_START]); @@ -165,6 +175,7 @@ default: printf(" recieved Message 0x%x \n",cmd[CMD_HDR_COMMAND]); } + } int cDriverPICCtl::Init() diff -r 9798f65f2f35 -r ccaf76b245ec graphlcd-base/glcddrivers/port.c --- a/graphlcd-base/glcddrivers/port.c Thu Feb 07 00:18:02 2008 +0000 +++ b/graphlcd-base/glcddrivers/port.c Thu Feb 07 00:45:43 2008 +0000 @@ -291,7 +291,7 @@ struct termios options; struct sigaction saio; - fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY); + fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY | O_NONBLOCK); if (fd == -1) { printf("error opening port\n");