mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
Bazaar/Serial : fixed compilation on OSX
git-svn-id: svn://ultimatepp.org/upp/trunk@10793 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
64de920fe7
commit
8cf30c9620
1 changed files with 9 additions and 13 deletions
|
|
@ -72,8 +72,6 @@ bool Serial::Open(String const &port, dword lSpeed, byte parity, byte bits, byte
|
|||
B38400, B57600, B115200, B230400
|
||||
};
|
||||
|
||||
int bits;
|
||||
|
||||
fd = open(port, O_RDWR | O_NOCTTY | O_NONBLOCK);
|
||||
if (fd < 0)
|
||||
{
|
||||
|
|
@ -91,7 +89,9 @@ bool Serial::Open(String const &port, dword lSpeed, byte parity, byte bits, byte
|
|||
errCode = DeviceError;
|
||||
return false;
|
||||
}
|
||||
if (ioctl(fd, TIOCMGET, &bits) < 0)
|
||||
|
||||
unsigned int ctl;
|
||||
if (ioctl(fd, TIOCMGET, &ctl) < 0)
|
||||
{
|
||||
// unable to query serial ports signals
|
||||
close(fd);
|
||||
|
|
@ -100,8 +100,8 @@ bool Serial::Open(String const &port, dword lSpeed, byte parity, byte bits, byte
|
|||
errCode = DeviceError;
|
||||
return false;
|
||||
}
|
||||
bits &= ~(TIOCM_DTR | TIOCM_RTS);
|
||||
if (ioctl(fd, TIOCMSET, &bits) < 0)
|
||||
ctl &= ~(TIOCM_DTR | TIOCM_RTS);
|
||||
if (ioctl(fd, TIOCMSET, &ctl) < 0)
|
||||
{
|
||||
// unable to control serial ports signals
|
||||
close(fd);
|
||||
|
|
@ -155,12 +155,6 @@ bool Serial::Open(String const &port, dword lSpeed, byte parity, byte bits, byte
|
|||
case ParityOdd:
|
||||
tty.c_cflag |= PARENB | PARODD;
|
||||
break;
|
||||
case ParityMark:
|
||||
tty.c_cflag |= PARENB | PARODD | CMSPAR;
|
||||
break;
|
||||
case ParitySpace:
|
||||
tty.c_cflag |= PARENB | CMSPAR;
|
||||
break;
|
||||
default:
|
||||
Close();
|
||||
isError = true;
|
||||
|
|
@ -466,7 +460,7 @@ bool Serial::Write(uint8_t const *buf, uint32_t len, uint32_t timeout)
|
|||
const uint8_t *dPos = buf;
|
||||
for (;;)
|
||||
{
|
||||
uint32_t written = write(fd, dPos, len);
|
||||
int written = write(fd, dPos, len);
|
||||
if (written == len)
|
||||
return true;
|
||||
if (written >= 0)
|
||||
|
|
@ -524,7 +518,7 @@ ArrayMap<String, String> Serial::GetSerialPorts(void)
|
|||
CFMutableDictionaryRef classesToMatch;
|
||||
io_iterator_t serialPortIterator;
|
||||
|
||||
if (IOMasterPort(NULL, &masterPort) != KERN_SUCCESS)
|
||||
if (IOMasterPort(0, &masterPort) != KERN_SUCCESS)
|
||||
return res;
|
||||
|
||||
// a usb-serial adaptor is usually considered a "modem",
|
||||
|
|
@ -550,6 +544,8 @@ ArrayMap<String, String> Serial::GetSerialPorts(void)
|
|||
return res;
|
||||
macos_ports(&serialPortIterator, res);
|
||||
IOObjectRelease(serialPortIterator);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue