Hello,
I wrote a very simple program to test the 633 (serial) from the linux test provided on the site.
I encounter a problem I can't understand.
Sometimes when I press a key, the incoming reponse contains "C=95(31 = Send Data to LCD...". I assume I haven't purge the buffer or something like that but i can't figured out what must be done.
Please help !
Here is the code :
I wrote a very simple program to test the 633 (serial) from the linux test provided on the site.
I encounter a problem I can't understand.
Sometimes when I press a key, the incoming reponse contains "C=95(31 = Send Data to LCD...". I assume I haven't purge the buffer or something like that but i can't figured out what must be done.
Please help !
Here is the code :
Code:
int main(int argc, char* argv[]) {
/* Port initialisation */
if ( Serial_Init(SERIALPORT,BAUDRATE)!=0 ) {
printf(" [LCD] Could not open port \"%s\" at \"%d\" baud.\n",SERIALPORT,BAUDRATE);
return(-1);
} else
printf(" [LCD] Running\n");
/* For some reason, Linux seems to buffer up data from the LCD, and they are sometimes
* dumped at the start of the program. Clear the serial buffer. */
while ( BytesAvail() ) GetByte();
/* Clear LCD */
outgoing_command.command = 6;
outgoing_command.data_length = 0;
send_packet();
/* Set mask */
outgoing_command.command = 23;
outgoing_command.data_length = 2;
/* Press mask */
outgoing_command.data[0] = KP_UP | KP_ENTER | KP_CANCEL | KP_LEFT | KP_RIGHT | KP_DOWN;
/* Release mask */
outgoing_command.data[1] = 0;
send_packet();
while (1) {
usleep(100000); /* 1/10 second */
/* Send line to the 633 using command 31 */
outgoing_command.command = 31;
outgoing_command.data[0]=0; /*col*/
outgoing_command.data[1]=1; /*row*/
memcpy(&outgoing_command.data[2],"Youhou",6);
outgoing_command.data_length = 8;
send_packet();
int k,timed_out;
timed_out = 1; /* default timed_out is true */
for(k=0;k<=100000;k++)
if ( check_for_packet() ) {
timed_out = 0; /* set timed_out to false */
break;
}
if(timed_out)
printf("Timed out waiting for a response.\n");
if( check_for_packet() )
ShowReceivedPacket();
}
Looking for additional LCD resources? Check out our LCD blog for the latest developments in LCD technology.