Skip navigation.
Home
The QNX Community Portal

View topic - Accessing device specific configuration

Accessing device specific configuration

For discussion of realtime and/or embedded programming.

Accessing device specific configuration

Postby ogr » Tue Oct 29, 2013 5:06 pm

Hi,

I'm trying to configure a MOXA CP-104JU multiport serial board.
The devc-ser8250 driver from QNX works OK with it, but to configure the serial ports as RS-485, 2 wires, you need to access device specific I/O.

I have a Linux source example where to configure the operation mode it uses the following instructions:

Code: Select all
#define MOXA_GET_OP_MODE                (0x400+67)

int mxsp_get_interface(unsigned int fd) {
   int mode;

   return ioctl(fd, MOXA_GET_OP_MODE, &mode)==0? mode:-1;
}


In QNX the ioctl call is different. How can I set the operation mode in QNX, in a similar way as the Linux code.

Thank you in advance.

ogr
ogr
Active Member
 
Posts: 28
Joined: Thu May 31, 2007 1:16 pm

Re: Accessing device specific configuration

Postby maschoen » Tue Oct 29, 2013 8:40 pm

I don't know if the serial driver supports this, however it should be fairly easy to get the source and check, and modify it if necessary.
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

Re: Accessing device specific configuration

Postby ogr » Wed Jan 08, 2014 11:06 am

I have a previous version of the code tbat was working for QNX 6.3. In this code the ioctl() function is used to configure the serial interface of a MOXA multiport serial board.

With QNX 6.5 this code is not working to configure the serial interfaces.

Is the behavior of the ioctl() function chenged from 6.3 to 6.5?
How can I reproduce the same behavior as in 6.3 version?

Below you can see the key part of the code:

Code: Select all
#define SET_OP_MODE        0x466
#define GET_OP_MODE        0x467

// Open the device node
fd = open(argv[1], O_RDWR);
if ( fd < 0 ) {
   printf("Open device node %s fail !\n", argv[1]);
   exit(1);
}

if ( argc <= 2 ) {
   ioctl(fd, GET_OP_MODE, &interface);
   switch ( interface ) {
   case RS232_MODE :
         printf("Now setting is RS232 interface.\n");
         break;
   case RS485_2WIRE_MODE :
      printf("Now setting is RS485-2WIRES interface.\n");
      break;
   case RS422_MODE :
      printf("Now setting is RS422 interface.\n");
      break;
   case RS485_4WIRE_MODE :
      printf("Now setting is RS485-4WIRES interface.\n");
      break;
   case NOT_SET_MODE :
      printf("Now does not set to any type interface.\n");
      break;
   default :
      printf("Unknow interface is set.\n");
   }
      close(fd);
      exit(0);
   }

sscanf(argv[2], "%d", &interface);
if ( interface != RS232_MODE &&
     interface != RS485_2WIRE_MODE &&
     interface != RS422_MODE &&
     interface != RS485_4WIRE_MODE ) {
   close(fd);
   printf("Error interface.\n");
   goto usage;
}

ioctl(fd, SET_OP_MODE, &interface);
close(fd);
exit(0);
ogr
Active Member
 
Posts: 28
Joined: Thu May 31, 2007 1:16 pm

Re: Accessing device specific configuration

Postby ogr » Wed Jan 08, 2014 11:11 am

I forgot to say that when ioctl() functions fails and taking the value returned by the ioctl() call it gives -1, and getting the errno value gives the error number 25 (“Inappropriate I/O control operation”).

In the Library Reference for QNX Neutrino 6.5.0, in the information for ioctl() this error corresponds to ENOTTY, which means:

“The fd argument isn’t associated with a character-special device; the specified request doesn’t apply to the kind of object that the descriptor fd references”.

As mentioned previously, it seems like the ioctl() behavior has changed in QNX 6.5.0.

Thanks

ogr
ogr
Active Member
 
Posts: 28
Joined: Thu May 31, 2007 1:16 pm


Return to Realtime and Embedded

Who is online

Users browsing this forum: No registered users and 1 guest

cron