Linux USB Serial sending 0x0D receiving 0x0A issue

Am using a FTDI serial to USB converter , today i encountered with a strange issue.When am sending an hexadecimal  0xD it is received as 0xA.

I tried to debug the code but was in vain,finaly i got a solution from stackoverflow the same issue was reported for a java program.

Typing these commands solved the issue

"stty -F /dev/ttyUSB0 -onclr"
"stty -F /dev/ttyUSB0 -icrnl"

icrnl – translate carriage return to newline

If you have a c program to open /dev/ttyUSB0 then add the below iflag


tty.c_iflag &= ~(INLCR | ICRNL);

Happy Hacking 🙂

Advertisements

Running a C program on mini2440

Am creating a simple Hello World program in C.This is the program

#include<stdio.h>
int main(){
 printf("Hello World\n");
}

saved it as hello.c..Now compiling it for our target or mini2440.

open terminal and change directory to the folder where c program is presnt and issue this command

arm-linux-gcc hello.c -o hello

The arm-linux-gcc command was present bcoz we setup the toolchain early.Now a binary hello will be present in the folder.use file command to know the type of the binary it will suitable for ARM.

Move the bianry to mini2440 using pendrive or sdcard.To see the output execute the binary like this..

./hello