clearing serial lcd
I am working on embedded linux, through one of serial ports i have connected Serial LCD (16x2)
i am writting data to it by write command.
char ch = "john";
it is displaying the text properly.
The issue is to clear the lcd i have to pass 0xC(hex) command to it.
here i am doing like this
char ch1 = 0x0C;
but here it is not clearing.
Kindly any one resolve this issue.
Thanks in advance
Ah... This threw me for a second, but I've got it:
Originally Posted by johnb4u
write(serial_fd, &ch1, sizeof(ch1));
Note the ampersand before "ch1" as the second argument...
When you pass an array as an argument to "write()", that array argument is treated as equivalent to the address of the first element in the array. But when you pass in a single character, what happens is the value of that character is converted into a pointer (0x0000000C on a 32-bit machine) - you must explicitly pass in the address to the character stored in ch1.