Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

Serial communication in linux

Status
Not open for further replies.

bakhat

Newbie level 6
Joined
Sep 8, 2004
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
189
Hellow Dears

i want to do serial communication using linux. i dont have any idea of programming in linux. can any one help me in doing the very basic serial communication on linux platform.
 

techie

Advanced Member level 3
Joined
Feb 5, 2002
Messages
839
Helped
58
Reputation
116
Reaction score
9
Trophy points
1,298
Location
Pakistan
Activity points
7,799
There are a few documets at tldp.org specifically on this subject.
 

bakhat

Newbie level 6
Joined
Sep 8, 2004
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
189
Hello,

I tried to access the serial port "com2" of ep9312. i used device file ttyAM1 but when i run programm the program access com1 of ep9312, i change the device file to ttyAM0 to use the other com port but the programm still uses the same come port. there are only 2 files in ramdisk "ttyAM0 and ttyAM1" both files using com1 How can i access the com2, is there any special device files fo it or i am doing any mistake i am using the programm

#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
int open_port();
int main()
{ struct termios options;
int i;
int n;
int fd;
int open_port(void)
{
fd=open("/dev/ttyAM1", O_RDWR | O_NOCTTY | O_NDELAY);
if (fd==-1)
{
perror("open_port: unable to open /dev/ttyAM1 - ");
}
else
fcntl(fd, F_SETFL, 0);
return (fd);
}
tcgetattr(fd, &options);
cfsetispeed(&options,B19200);
cfsetospeed(&options,B19200);
options.c_cflag |= ( CLOCAL | CREAD);
tcsetattr(fd, TCSANOW, &options);
for (i=0; i<=10; i++)
{
n= write(fd, "----- O AKBER\n", 14);
write(fd, "Hello World\n", 12);
if (n<0)
fputs("write() of 4 bytes failed!\n", stderr);
}
return 0;
}

I complaid this code with ARM cross compiler provided by cirrus logic cross compiler 2.95.3
i am stucked here,
can any one tell what is the problem?
 

rave

Member level 1
Joined
Dec 31, 1999
Messages
35
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Activity points
152
hello
see linux application development book
 

quacklamack

Junior Member level 3
Joined
Dec 7, 2001
Messages
28
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
220
If you are fluent with Python, you whould definitely try Pyserial.. It makes easy for you to learn the basics of serial and then you can apply the same concepts in C.</p>



Just browse this program, from the page. How could it be simpler?</p>

<tt>
Open port 0 at "9600,8,N,1", no timeout

>>> import serial
>>> ser = serial.Serial(0) #open first serial port
>>> print ser.portstr #check which port was realy used
>>> ser.write("hello") #write a string
>>> ser.close() #close port
</tt>



Quack</p>
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top