Results 1 to 3 of 3
Hi,
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[5] = ...
- 07-22-2009 #1Just Joined!
- Join Date
- Jul 2009
- Posts
- 16
clearing serial lcd
Hi,
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[5] = "john";
write(serial_fd,ch,sizeof(ch))
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;
write(serial_fd,ch1,sizeof(ch1));
but here it is not clearing.
Kindly any one resolve this issue.
Thanks in advance
John
- 07-23-2009 #2
Ah... This threw me for a second, but I've got it:
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.
- 07-25-2009 #3Just Joined!
- Join Date
- Jul 2009
- Posts
- 16
Thankyou tetsujin,
its resolved.


Reply With Quote
