ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I have been trying to communicate with device trhough /dev/ttyS0.
The device sends out data as soon as it powers up but the read just gets stuck and I cant proceed any further. After the initial startup data from the device, commands can be sent to it to control it. I can send one command to it successfully but after that I cant control the device.
Could the serial port be blocked by the kernel for some reason or is my code itself wrong. I have posted the code below and I would be grateful for any help regarding this.
printf("%s","error in setting up device\n\n");
printf("%s","trying to read");
bytes=fcntl(fd,F_SETFL,FNDELAY); //to avoid serial port blocking
res=read(fd,buff,100); //trying to read initial setup data-not working
n=write(fd,"debug d 35 5 0\r",1000); //writing command to WSS
The state of your new struct termios, nw, is indeterminate. Try zeroing it before setting bits and bytes.
You probably want to set VMIN & VTIME in the termios, since you are using raw mode. See the Serial Programming Howto, especially the section named 'Non-Canonical Input Processing'. It is hard to predict the right settings for your application without knowing more about the data. The essential problem, as I see it, is that you are going to have to read iteratively, and accumulate and/or parse data as it arrives, since raw mode input cannot know how to break up the input stream in a way that is suitable for your application.