Find the answer to your Linux question:
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] = ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just 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

  2. #2
    Linux Newbie tetsujin's Avatar
    Join Date
    Oct 2008
    Posts
    117
    Quote Originally Posted by johnb4u View Post
    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
    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.

  3. #3
    Just Joined!
    Join Date
    Jul 2009
    Posts
    16
    Thankyou tetsujin,
    its resolved.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •