LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-21-2008, 09:47 AM   #1
andaya
LQ Newbie
 
Registered: Oct 2008
Posts: 6

Rep: Reputation: 0
Problem with serial port, it lost some bytes !!!!!!


Hello,

Let me introduce myself, I am Juan from Spain. I am developing application with linux and I have not enough experience with linux.
I will hope to find answer and more questions to learn more about linux.

In this moment, I have a problem.

I use a Visual basic application to send commands to programm in embbeded linux.

The problem is that it lost some bytes, and I do not known what is the problem.

This is my configuration:

Quote:
Speed: 38400, 8N1,no flow control, and raw input

tcgetattr(fd, &options_new);

cfsetispeed(&options_new, B38400);
cfsetospeed(&options_new, B38400);

options_new.c_cflag |= (CLOCAL | CREAD);

options_new.c_cflag &= ~PARENB;
options_new.c_cflag &= ~CSTOPB;
options_new.c_cflag &= ~CSIZE;
options_new.c_cflag |= CS8;

options_new.c_cflag &= ~(IXON | IXOFF | IXANY);

options_new.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);

tcsetattr(fd, TCSANOW, &options_new);
Visual basic send the same command all the time:

Quote:
0 1 1 2 2 0 1f 8 0 4 b 6 3 a 2 8 0 4 b 6 3 8 2 8 0 4 b 8 4 4 2
0 1 1 2 2 0 1f 8 0 4 b 6 3 a 2 8 0 4 b 6 3 8 2 8 0 4 b 8 4 4 2
0 1 1 2 2 0 1f 8 0 4 b 6 3 a 2 8 0 4 b 6 3 8 2 8 0 4 b 8 4 4 2
0 1 1 2 2 0 1f 8 0 4 b 6 3 a 2 8 0 4 b 6 3 8 2 8 0 4 b 8 4 4 2
0 1 1 2 2 0 1f 8 0 4 b 6 3 a 2 8 0 4 b 6 3 8 2 8 0 4 b 8 4 4 2
0 1 1 2 2 0 1f 8 0 4 b 6 3 a 2 8 0 4 b 6 3 8 2 8 0 4 b 8 4 4 2
0 1 1 2 2 0 1f 8 0 4 b 6 3 a 2 8 0 4 b 6 3 8 2 8 0 4 b 8 4 4 2
0 1 1 2 2 0 1f 8 0 4 b 6 3 a 2 8 0 4 b 6 3 8 2 8 0 4 b 8 4 4 2
0 1 1 2 2 0 1f 8
0 1 1 2 2 0 1f 8 0 4 b 6 3 a 2 8 0 4 b 6 3 8 2 8 0 4 b 8 4 4 2
0 1 1 2 2 0 1f 8 0 4 b 6 3 a 2 8 0 4 b 6 3 8 2 8 0 4 b 8 4 4 2
0 1 1 2 2 0 1f 8 0 4 b 6 3 a 2 8 0 4 b 6 3 8 2 8 0 4 b 8 4 4 2
0 1 1 2 2 0 1f 8 0 4 b 6 3 a 2 8 0 4 b 6 3 8 2 8 0 4 b 8 4 4 2
0 1 1 2 2 0 1f 8 0 4 b 6 3 a 2 8 0 4 b 6 3 8 2 8 0 4 b 8 4 4 2
But as you see, some times, serial port lost some bytes.

Is there any issue for this problem????

Best reagards
 
Old 10-22-2008, 03:03 AM   #2
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
Can you be clearer about your situation: I think you mean that you have two computers, One desktop/server type machine which runs Visual Basic and the other an embedded computer. The desktop/server one sends out the stream of data. Is this the right picture? Are you communicating via RS 232 or is it some other serial comm 'standard'?

Code:
Speed: 38400, 8N1,no flow control, and raw input
"No flow control" can give exactly this kind of problem; if the receiving end is too busy to cope with the data flow at exactly the right time, you will get a buffer overrun and lose data in exactly this manner.

You will want to get both ends using the same kind of flow control (XON/XOFF or hardware). XON/XOFF makes the cabling simpler (and don't ask about a standard RS232 cable), but means that the applications have to do something about the possibility of XON/XOFF chars in the data stream.

The other obvious possibility is that you have a data stream that contains characters which are interpreted as having a special meaning, like the XON XOFF chars.

One question that might clarify the issue is whether you always get the same loss of chars, or whether it varies from time to time.
 
Old 10-22-2008, 04:49 AM   #3
andaya
LQ Newbie
 
Registered: Oct 2008
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by salasi View Post
Can you be clearer about your situation: I think you mean that you have two computers, One desktop/server type machine which runs Visual Basic and the other an embedded computer. The desktop/server one sends out the stream of data. Is this the right picture? Are you communicating via RS 232 or is it some other serial comm 'standard'?

Code:
Speed: 38400, 8N1,no flow control, and raw input
"No flow control" can give exactly this kind of problem; if the receiving end is too busy to cope with the data flow at exactly the right time, you will get a buffer overrun and lose data in exactly this manner.

You will want to get both ends using the same kind of flow control (XON/XOFF or hardware). XON/XOFF makes the cabling simpler (and don't ask about a standard RS232 cable), but means that the applications have to do something about the possibility of XON/XOFF chars in the data stream.

The other obvious possibility is that you have a data stream that contains characters which are interpreted as having a special meaning, like the XON XOFF chars.

One question that might clarify the issue is whether you always get the same loss of chars, or whether it varies from time to time.
I am sorry if I did not be clearer.

Yes , you are right, I have two computer, my laptop connected to embedded computer with a serial cable, at the begining, only 3 wires, RXD, TXD and GND.
Configuration of serial port:
Speed: 38400, 8N1,no flow control, and raw input.

As I understand, perhaps my problem is a buffer overrun and lose some bytes. So I suppoose that I need some control, like XON/XOFF, but I never use it. How I need to use it, serial cable with all wires???

And I am sorry if I did not clear question.

Best regards
 
Old 10-23-2008, 02:45 AM   #4
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
Quote:
As I understand, perhaps my problem is a buffer overrun and lose some bytes. So I suppoose that I need some control, like XON/XOFF, but I never use it. How I need to use it, serial cable with all wires???
See previous reply; you need to choose between hardware (more wires!) and software (issues if the data can contain the control code!) flow control methods; you need exactly one of the two.
 
  


Reply



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
serial port problem bekaar Ubuntu 2 03-24-2007 06:44 PM
Problem with serial port billyseth Linux - Kernel 1 10-27-2006 01:07 PM
Serial port problem floydes Programming 1 10-14-2004 11:50 AM
No of bytes in the serial drivers transmit buffer igjesdal Programming 0 10-13-2004 10:58 AM
Problem with Serial port mritunjay Linux - Networking 1 04-22-2002 01:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:33 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