LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-03-2018, 09:13 AM   #16
pkthapa
LQ Newbie
 
Registered: Oct 2018
Posts: 1

Rep: Reputation: Disabled
Reading 0x09 data more than once.


I had also faced this issue (0x0D converted to 0x0A on Linux system). On executing below commands the issue was resolved.

stty -F /dev/ttyUSB0 -onlcr
stty -F /dev/ttyUSB0 -icrnl


There is one more similar issue being encountered everytime. If the data stream contains 0x09, then 0x09 is being read more than the actual presence count.

Actual data stream:
data[0] = 0x04
data[1] = 0x80
data[2] = 0x09
data[3] = 0x01
data[4] = 0x72
data[5] = 0x13
data[6] = 0x22

Output data stream (incorrectly read):
data[0] = 0x04
data[1] = 0x80
data[2] = 0x09
data[3] = 0x09 //Incorrect data
data[4] = 0x01
data[5] = 0x72
data[6] = 0x13
data[7] = 0x22 //This data is discarded from the main data stream.

This happens only when 0x09 data is present in the data stream. 0x09 is the ASCII code of horizontal tab character.

Need experts comments for this issue. Looks like incorrectly set port attributes. Please correct me if I am wrong.

Thank you,
Pankaj

------------------------------------------------------------------------------------

Quote:
Originally Posted by esi-eric View Post
Greetings Osvaldo!

tnew.c_iflag &= ~INLCR; /* do not translate 0x0A to 0x0D

I have inserted the above line into the serial port initialization code and it still fails! I have the
reverse problem whereas a 0x0D is translated into a 0x0A! Not a 0x0A into a 0x0D...the 0x0D is
correct and the 0x0A is incorrect!

Thank you very much! and p.s. I am still at work debugging this thing!!!!!

Where can I get a list of these control bytes like "INLCR" for my reference?

Thank you very much once again!

Eric.

------------------------------------------------------------------------------------
I have inserted the following line into the code and it works!!!!
tnew.c_iflag &= ~ICRNL; /* do not translate 0x0D to 0x0A */

Do I still need your code as well to not translate 0x0A to 0x0D????

Thank you very much once again!!!!! I think we finally got this working!!!!!

Eric.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problems reading back from socket chr15t0 Programming 2 11-16-2005 08:40 AM
reading data from a serial port mchitrakar Linux - Networking 3 12-04-2004 01:24 PM
problems reading audio CDs, data DVDs and CD-Rs umberleigh Linux - Hardware 4 07-29-2004 07:46 AM
Problem in reading/writing binary data in Linux esi-eric Linux - Hardware 3 07-20-2004 04:21 PM
having problems reading data into a C program Hockeyfan Programming 2 05-24-2004 04:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration