ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have borrowed a simple program that is supposed to read from a file and
output to the screen. Simply pass the file to it at the command line. I am
pointing it at a serial port, instead of a regular file and I get different results when I run it from the old C++ compiler instead
of the new. Any help is VERY VERY appreciated. I am not sure if I am
simply not using the new standard appropriately, or if my system is
configured incorrectly, or the compiler.
Here are the specifics:
System: Suse Linux 9.0 (i586) Kernel 2.4.21-243-smp4G
Old compiler: g++ using gcc version 2.95.3 20010315 (release)
New compiler: g++ using gcc version 3.3.3 (SuSE Linux)
to run command line: a.out /dev/ttyS0
What happens:
When I compile under the old compiler it works fine, I send info down the
port, it reads it and displays it on my screen.
When I compile under the new compiler, it simply blocks, no info is read,
the program never proceeds past the first get().
Here is the code:
#include <fstream>
#include <iostream>
using namespace std;
int main (int argc, char* argv[])
{
ifstream file;
Can't say exactly what the diff is between the two compilers, though I'm not surprised it happens. You need to do more than just open the tty file and read from it, there is a lot of other things to configure. You'll need to understand your hardware, and if it uses flow control and what kind so you can set your rts and dtr as required, also baud rate, etc...
I've written a C serial library, what's the best way to get it to you. Its too large to post here. You can email me if you want it.
I must have just gotten lucky with the old compiler. I have done serial communications using C before, and was impressed with how easy it was to use C++, I was just fooling myself...;-) Thanks again.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.