title: Sending Hexadecimal data through Serial Port Communication in Linux
body: <p>I have got a task of sending hexadecimal data to my COMPORT in linux. I have written this simple C code, but it sends only a decimal number. Can anyone help me in sending an hexadecimal bit.</p>
  
  <p>Here is the code I have written</p>
  
  <pre><code>#include &lt;stdio.h&gt;   /* Standard input/output definitions */
  #include &lt;string.h&gt;  /* String function definitions */
  #include &lt;unistd.h&gt;  /* UNIX standard function definitions */
  #include &lt;fcntl.h&gt;   /* File control definitions */
  #include &lt;errno.h&gt;   /* Error number definitions */
  #include &lt;termios.h&gt; /* POSIX terminal control definitions */
  
  int number,n;
  void main(void){
  open_port(); 
  }
  
    int open_port(void)
  {
    int fd; /* File descriptor for the port */
  
  
    fd = open("/dev/ttyACM0", O_RDWR | O_NOCTTY | O_NDELAY);
    if (fd == -1)
    {
  
  perror("open_port: Unable to open /dev/ttyACM0 - ");
    }
    else{
       printf("Port Opened successfully\n");
       number = 1;
       while(number!=55){
       scanf("%d",&amp;number);
        n = write(fd, "ATZ\r", number);
       if (n &lt; 0)
       fputs("write() of 4 bytes failed!\n", stderr);
       }
  
  
  }
  
    return (fd);
  }
  </code></pre>
  
  <p>Please help</p>
  
  <p>Thanks in advance :) :)</p>