Skip to content

Commit

Permalink
Re-did Pepijn de Vos changes because of git issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nyholku committed Apr 2, 2012
1 parent dbc9895 commit f38b146
Showing 1 changed file with 80 additions and 73 deletions.
153 changes: 80 additions & 73 deletions src/purejavacomm/PureJavaSerialPort.java
Expand Up @@ -33,6 +33,8 @@
import java.io.*;
import java.util.*;

import com.sun.jna.Platform;

import jtermios.*;

import static jtermios.JTermios.JTermiosLogging.*;
Expand Down Expand Up @@ -392,80 +394,85 @@ synchronized public void setSerialPortParams(int baudRate, int dataBits, int sto
prev.set(m_Termios);

try {
int br = baudRate;
switch (baudRate) {
case 50:
br = B50;
break;
case 75:
br = B75;
break;
case 110:
br = B110;
break;
case 134:
br = B134;
break;
case 150:
br = B150;
break;
case 200:
br = B200;
break;
case 300:
br = B300;
break;
case 600:
br = B600;
break;
case 1200:
br = B1200;
break;
case 1800:
br = B1800;
break;
case 2400:
br = B2400;
break;
case 4800:
br = B4800;
break;
case 9600:
br = B9600;
break;
case 19200:
br = B19200;
break;
case 38400:
br = B38400;
break;
case 7200:
br = B7200;
break;
case 14400:
br = B14400;
break;
case 28800:
br = B28800;
break;
case 57600:
br = B57600;
break;
case 76800:
br = B76800;
break;
case 115200:
br = B115200;
break;
case 230400:
br = B230400;
break;
if (Platform.isMac()) {
int[] data = new int[] {baudRate};
checkReturnCode(ioctl(m_FD, 0x80045402, data));
} else {
int br = baudRate;
switch (baudRate) {
case 50:
br = B50;
break;
case 75:
br = B75;
break;
case 110:
br = B110;
break;
case 134:
br = B134;
break;
case 150:
br = B150;
break;
case 200:
br = B200;
break;
case 300:
br = B300;
break;
case 600:
br = B600;
break;
case 1200:
br = B1200;
break;
case 1800:
br = B1800;
break;
case 2400:
br = B2400;
break;
case 4800:
br = B4800;
break;
case 9600:
br = B9600;
break;
case 19200:
br = B19200;
break;
case 38400:
br = B38400;
break;
case 7200:
br = B7200;
break;
case 14400:
br = B14400;
break;
case 28800:
br = B28800;
break;
case 57600:
br = B57600;
break;
case 76800:
br = B76800;
break;
case 115200:
br = B115200;
break;
case 230400:
br = B230400;
break;
}
// try to set the baud rate before anything else
// as it may fail at 'tcsetattr' stage and in that
// case we do not want to change anything
checkReturnCode(cfsetispeed(m_Termios, br));
checkReturnCode(cfsetospeed(m_Termios, br));
}
// try to set the baud rate before anything else
// as it may fail at 'tcsetattr' stage and in that
// case we do not want to change anything
checkReturnCode(cfsetispeed(m_Termios, br));
checkReturnCode(cfsetospeed(m_Termios, br));

int db;
switch (dataBits) {
Expand Down

0 comments on commit f38b146

Please sign in to comment.