LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 12-01-2008, 05:57 PM   #1
scrawny_1
LQ Newbie
 
Registered: Feb 2008
Location: Queensland
Distribution: Redhat EL5
Posts: 8

Rep: Reputation: 0
Really high IRQ values???


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.

Please help.

-Scrawny
 
Old 12-03-2008, 10:12 AM   #2
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
Let me start off by saying that I know very little about this.

I have a Davis Vantage Pro II weather station plugged into com1 and it just worked. I communicate with it using C++ programs that I have written.

What are you using to communicate with your A-B box?

To troubleshoot, can you unplug whatever you have hooked to com1 and try your A-B box there?
 
Old 12-08-2008, 10:27 PM   #3
scrawny_1
LQ Newbie
 
Registered: Feb 2008
Location: Queensland
Distribution: Redhat EL5
Posts: 8

Original Poster
Rep: Reputation: 0
Question

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 */

#include "/u/t35/include/global.h"
#include "/u/t35/include/config.h"
#include <sys/ioctl.h>
#include <stdio.h>
#include <signal.h>
#include <fcntl.h>
#include <termio.h>
#include <unistd.h>

/*
** 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
*/

if (ioctl(iodevfdes,TCGETA,&iob) == ERROR) {
sprintf(&evstr[0],"AMGR: Openpd: can't ioctl %s\n",iodevname);
frrlog(&evstr[0]);
exit(-1);
}

iob.c_cflag = iodevioctl; /* tty control word */

iob.c_iflag &= ~IGNPAR; /* ignore parity errors */
iob.c_iflag &= ~INPCK; /* disable parity check */
iob.c_iflag &= ~BRKINT; /* ignore line breaks */
iob.c_iflag &= ~ISTRIP; /* don't strip bit 8 */

iob.c_oflag &= ~OPOST; /* no post process on o/p*/

iob.c_lflag = 0 ;
iob.c_cc[4] = (char)1; /* MIN number of characters */
iob.c_cc[5] = (char)50; /* Time out .3 secs */

if (ioctl(iodevfdes,TCSETA,&iob) == ERROR) {
sprintf(&evstr[0],"AMGR: Openpd: can't ioctl %s", iodevname);
frrlog(&evstr[0]);
exit(-1);
}

(void)ioctl(iodevfdes,TCFLSH,0);

}

/***********************************************************************
*
* getcpd - gets a character from the handler's protocol device
*
**********************************************************************/

getcpd()
{
extern int status;
char c;
long time();
uint alarm();

#define DLEN 120
static char dbuf[DLEN];
static char *dp = &dbuf[0];
static char *dop;
static int dcnt;
char df, dc;

try_again:
(void)signal(SIGALRM,onint); /* set alarm signal for trap by onint*/
(void)alarm(IOSECS);

status = read(iodevfdes,&c,1);

(void)alarm(0);
(void)signal(SIGALRM,SIG_IGN);

if (status == -1) {
sprintf(&evstr[0],"AMGR: Getcpd (amgr): -1 status\n");
frrlog(&evstr[0]);
return (IO_TIMEOUT);
} else if (status == 0) {
sprintf(&evstr[0],"AMGR: Getcpd (amgr): 0 status\n");
frrlog(&evstr[0]);
sleep(1);
goto try_again;
} else {
return (c & 0377);
}
}
 
Old 12-10-2008, 10:54 AM   #4
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
I'm not clear whether your program is making it to this line:
Code:
if (status == -1)
or not. If it is, could the following be your problem?
Quote:
From here:

"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."
 
Old 12-15-2008, 05:50 AM   #5
scrawny_1
LQ Newbie
 
Registered: Feb 2008
Location: Queensland
Distribution: Redhat EL5
Posts: 8

Original Poster
Rep: Reputation: 0
Hmmmm... interesting point. The code does get to that point. I have inserted a couple of debug statements and the code:
Code:
sprintf(&evstr[0],"AMGR: Getcpd (amgr): -1 status\n");
frrlog(&evstr[0]);
writes the string to an error dump file.

I keep thinking it might be the hardware...

Would the BAUD rate or the error checking or the XON/XOFF have anything to do with it?
 
Old 12-15-2008, 09:45 AM   #6
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
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);
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
uniq/ awk/ or sed trying to get high / low values schneidz Programming 3 06-18-2008 02:30 PM
Realtek RTL8111/8168B IRQ clash? Hardware errors with high activity madbrad Linux - Networking 10 02-23-2008 10:35 PM
Load Avg High/Phys Mem High teamh Debian 2 12-26-2006 05:03 PM
process priority,nice -- small question regarding high/low priority values beeblequix Linux - Newbie 1 10-11-2006 10:22 AM
SCSI Errors when IRQ Shared - How do I not share IRQ MQMan Linux - Hardware 2 01-08-2006 11:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:05 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration