Linux - NewbieThis 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
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 decided to place this question in the newbie section as it's probably a no-brainer.
I have attached a serial PCI card to my RHEL4 linux machine and the IRQ assigned to it is 209. Which seems rather high. The IO is 0x2440. Is this right? I thought interrupts only went so far. Also it's not in the IRQ table in /proc/interrupts.
dmesg | grep tty gives this:
ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
ttyS4 at I/O 0x2440 (irq = 209) is a 16550A
The new device is ttyS4. I need it to talk to an old allen bradley box but it's not working. How do I know if it's "installed" correctly?
Have tried assigning a lower IRQ and IO with 'setserial' which has produced erroneous results.
Hi! I use some C code to open and read the port. It's falling over at a read statement:
status = read(iodevfdes,&c,1);
According to the 'read' function in unistd.h '-1' is 'errors'.
Here's the code:
*/
/*
** openpd open protocol handler device port
**
*/
#define IOSECS 8 /* seconds to wait for IO completion */
/*
** global variables describing the device
*/
extern char *iodevname; /* device name (see configure) */
extern uint iodevioctl; /* required ioctl parameters (see configure) */
extern int iodevfdes; /* device file descriptor */
extern char evstr[];
void onint();
openpd()
{
extern void exit();
struct termio iob;
/*
* open the device as indicated in the config table
* and setup the file descriptor
*/
if ((iodevfdes=open(iodevname,O_RDWR|O_NONBLOCK)) == BAD_OPEN) {
sprintf(&evstr[0],"AMGR: Openpd : can't open %s\n",iodevname);
frrlog(&evstr[0]);
exit(-1);
}
sprintf(&evstr[0],"AMGR: Openpd: iodevname <%s>\n",iodevname);
frrlog(&evstr[0]);
sprintf(&evstr[0],"AMGR: Openpd: iodevioctl <%ld>\n",iodevioctl)
;
frrlog(&evstr[0]);
sprintf(&evstr[0],"AMGR: Openpd: iodevfdes <%ld>\n",iodevfdes);
frrlog(&evstr[0]);
/*
* set up the opened port for RAW i/o
*/
/***********************************************************************
*
* getcpd - gets a character from the handler's protocol device
*
**********************************************************************/
getcpd()
{
extern int status;
char c;
long time();
uint alarm();
"If a non-blocking instruction tries to read a port, if no data is available, it will normally return an error or status indicator and allow the program to continue."
Could be the hardware. As I stated above I'm no expert, but ...
My serial device does not send data unless I send it a command. If the port is opened O_NONBLOCK, reading from it without sending a command (no data available) returns "-1". If I open and read from it without the O_NONBLOCK flag it returns "0"
Seems to me you need to either remove the O_NONBLOCK from the open statement or change the code in the getcpd function to something like
Code:
while ( x < 60 ) // a counter for how long you wait for data
{
status = read(iodevfdes,&c,1);
if (status == -1 ) sleep(1);
else return (c & 0377);
x++;
}
return (IO_TIMEOUT);
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.