473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

setting port in linux and windows

I code a program which two computer communicate each other with serial port in cross platform but my program dont run cross platform but run linux to linux or windows to windows . I think my serial port settings arent the same.My settings:

WINDOWS:
DCB properties;
GetCommState(serialPort, &properties);

properties.Parity = NOPARITY;
properties.BaudRate=9600;
properties.ByteSize = 8;
properties.StopBits = ONESTOPBIT;

SetCommState(serialPort, &properties);

LINUX:

struct termios properties;

tcgetattr(serialPort, &properties);

properties.c_cflag = CS8|CREAD|B9600|CLOCAL;
properties.c_iflag = IGNBRK;
properties.c_oflag = 0;
properties.c_lflag = 0;
properties.c_cc[VMIN] = 1;
properties.c_cc[VTIME]= 0;

tcsetattr(serialPort, TCSANOW, &properties);
Dec 19 '06 #1
4 5132
horace1
1,510 Expert 1GB
code looks OK, possibly one side is using hardware handshaking and the other not.

Have a look at my serial code for windows and linux
http://www.geocities.com/horacespider/Serial_IO/
Dec 19 '06 #2
thank you...I dont use hardware handshaking.....
Dec 20 '06 #3
Banfa
9,065 Expert Mod 8TB
This line correct ?

properties.c_cflag = CS8|CREAD|B9600|CLOCAL;

Looking at the documentation online is says that the baud rates must be set using the functions cfsetospeed and cfsetispeed
Dec 20 '06 #4
horace1
1,510 Expert 1GB
This line correct ?

properties.c_cflag = CS8|CREAD|B9600|CLOCAL;

Looking at the documentation online is says that the baud rates must be set using the functions cfsetospeed and cfsetispeed
I have used the following in one of my programs
Expand|Select|Wrap|Line Numbers
  1.      struct termios newtio;
  2.       newtio.c_cflag = BAUD | CRTSCTS | DATABITS | STOPBITS | PARITYON | PARITY | CLOCAL | CREAD;
  3.       newtio.c_iflag = IGNPAR;
  4.       newtio.c_oflag = 0;
  5.       newtio.c_lflag = 0;       //ICANON;
  6.       newtio.c_cc[VMIN]=1;
  7.       newtio.c_cc[VTIME]=0;
  8.       tcflush(fd, TCIFLUSH);
  9.       tcsetattr(fd,TCSANOW,&newtio);
  10.  
where BAUD is B9600, DATABITS is CS8, etc
Dec 20 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Jorge Godoy | last post by:
Hi! We're doing a research project that involves controlling mini-windtrap speeds and we're reading/writing data from the parallel port. What I've found so far on a fast Google search for...
6
by: engsol | last post by:
I didn't fully think through my application before posting my question. Async com port routines to handle com port interrups only work well if one has access to the low level operating system. In...
6
by: Peter Krikelis | last post by:
Hi All, I am having a problem setting up input mode for serial communications. (Sorry about the long code post). The following code is what I use to set up my comm port.
3
by: Sells, Fred | last post by:
I'm using MSW XP Pro with Python 2.4 to develop but production will be Linux with Python 2.3. (could upgrade to 2.4 if absolutely necessary) I can also switch to Linux for development if...
2
by: py | last post by:
Is there a way in python to figure out which process is running on which port? I know in Windows XP you can run "netstat -o" and see the process ID for each open port....but I am looking for...
12
by: david.brown.0 | last post by:
I'm trying to make a Java program access a parallel port. Java's comm API does not provide me with the control I need. I need to be able to write to the data and control pins and read the status...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
1
by: platso | last post by:
Hi all, I have an application which will run in both windows as well as Linux. I ported it long back and it is working well. Now we need to extend the functionality ,so i have written .dll's...
4
by: Soren | last post by:
Hi, I want to control some motors using the parallel port.. however, my laptop does not have any parallel ports (very few do). What I do have is a USB->Parallel converter... I thought about...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.