My application can use usb to serial converter to print on printers that have only the serial port. It worked well on Tiger, but on Leopard I have several issues. I use two different converters: Keyspan and some generic converter - "Prolific based device" you can find in every other computer shop. For the second one I use drivers I found on serialio.com for both ppc & intel.
On Leopard, both converters are taken by the system and reserved for use for modem communication. Call to open() function fails. I can solve this for the second adapter by going to System preferences -> Network and manually removing the converter from the list.
I can not make the Keyspan adapter to work on Leopard - open() fails whatever I try.
Next problem I had was that with Prolific adapter I could open the port, print and close it only once. The second time, open() and close() calls would succeed, but write() function returns -1 and errno is set to 35 and strerror(errno) returns "service temporarily unavailable."
On Tiger it all works well with both Keyspan and this Prolific converter. I spent some time with the code and managed to make it work on Leopard, at least with Prolific but I'm not really sure exactly what I'm doing and will it stop working in Snow Leopard. So, this version of port setup worked only on Tiger:
This code works on Leopard so second time I use the port write() does not return -1 and all prints well:
I added those lines after googling for a while, but I would appreciate if anyone could help me with explanation why it works now.
At least, does anyone know how to make it all work on Keyspan and how do I prevent Leopard from stealing these adapters and treating them as modem ports.
On Leopard, both converters are taken by the system and reserved for use for modem communication. Call to open() function fails. I can solve this for the second adapter by going to System preferences -> Network and manually removing the converter from the list.
I can not make the Keyspan adapter to work on Leopard - open() fails whatever I try.
Next problem I had was that with Prolific adapter I could open the port, print and close it only once. The second time, open() and close() calls would succeed, but write() function returns -1 and errno is set to 35 and strerror(errno) returns "service temporarily unavailable."
On Tiger it all works well with both Keyspan and this Prolific converter. I spent some time with the code and managed to make it work on Leopard, at least with Prolific but I'm not really sure exactly what I'm doing and will it stop working in Snow Leopard. So, this version of port setup worked only on Tiger:
Code:
struct termios theTermios;
int retVal, modem;
retVal = tcgetattr (fd, &theTermios);
if (!retVal) {
memset (&theTermios, 0, sizeof(struct termios));
cfmakeraw (&theTermios);
cfsetspeed (&theTermios, B9600);
theTermios.c_cflag |= CS8;
retVal = tcsetattr(fd, TCSANOW, &theTermios);
}
return (retVal);
Code:
struct termios theTermios;
int retVal, modem;
retVal = tcgetattr (fd, &theTermios);
if (!retVal) {
memset (&theTermios, 0, sizeof(struct termios));
cfmakeraw (&theTermios);
theTermios.c_cc[VMIN] = 0; // NEW
theTermios.c_cc[VTIME] = 10; // NEW
cfsetspeed (&theTermios, B9600);
theTermios.c_cflag = CREAD | CLOCAL; // NEW
theTermios.c_cflag |= CS8;
retVal = tcsetattr(fd, TCSANOW, &theTermios);
}
return (retVal);
I added those lines after googling for a while, but I would appreciate if anyone could help me with explanation why it works now.
At least, does anyone know how to make it all work on Keyspan and how do I prevent Leopard from stealing these adapters and treating them as modem ports.