Format ports/bsd for standard style.
This commit is contained in:
+29
-18
@@ -864,8 +864,9 @@ bool dlmstp_init(void *poPort, char *ifname)
|
||||
exit(-1);
|
||||
}
|
||||
if (ioctl(poSharedData->RS485_Handle, TIOCEXCL) == -1) {
|
||||
printf("Error setting TIOCEXCL on %s - %s(%d).\n", poSharedData->RS485_Port_Name,
|
||||
strerror(errno), errno);
|
||||
printf(
|
||||
"Error setting TIOCEXCL on %s - %s(%d).\n",
|
||||
poSharedData->RS485_Port_Name, strerror(errno), errno);
|
||||
exit(-1);
|
||||
}
|
||||
#if 0
|
||||
@@ -887,13 +888,15 @@ bool dlmstp_init(void *poPort, char *ifname)
|
||||
CREAD : enable receiving characters
|
||||
*/
|
||||
printf(
|
||||
"Default/current input baud rate is %d\n", (int)cfgetispeed(&poSharedData->RS485_oldtio));
|
||||
"Default/current input baud rate is %d\n",
|
||||
(int)cfgetispeed(&poSharedData->RS485_oldtio));
|
||||
printf(
|
||||
"Default/current output baud rate is %d\n", (int)cfgetospeed(&poSharedData->RS485_oldtio));
|
||||
"Default/current output baud rate is %d\n",
|
||||
(int)cfgetospeed(&poSharedData->RS485_oldtio));
|
||||
newtio.c_cc[VMIN] = 0;
|
||||
newtio.c_cc[VTIME] = 10;
|
||||
//newtio.c_cflag =
|
||||
// poSharedData->RS485_Baud | poSharedData->RS485MOD | CLOCAL | CREAD;
|
||||
// newtio.c_cflag =
|
||||
// poSharedData->RS485_Baud | poSharedData->RS485MOD | CLOCAL | CREAD;
|
||||
cfsetspeed(&newtio, poSharedData->RS485_Baud);
|
||||
newtio.c_cflag &= ~PARENB; /* No Parity */
|
||||
newtio.c_cflag &= ~CSTOPB; /* 1 Stop Bit */
|
||||
@@ -905,8 +908,11 @@ bool dlmstp_init(void *poPort, char *ifname)
|
||||
newtio.c_oflag = 0;
|
||||
/* no processing */
|
||||
newtio.c_lflag = 0;
|
||||
if (ioctl(poSharedData->RS485_Handle, IOSSIOSPEED, &poSharedData->RS485_Baud) == -1) {
|
||||
printf("Error calling ioctl(..., IOSSIOSPEED, ...) %s - %s(%d).\n",
|
||||
if (ioctl(
|
||||
poSharedData->RS485_Handle, IOSSIOSPEED,
|
||||
&poSharedData->RS485_Baud) == -1) {
|
||||
printf(
|
||||
"Error calling ioctl(..., IOSSIOSPEED, ...) %s - %s(%d).\n",
|
||||
poSharedData->RS485_Port_Name, strerror(errno), errno);
|
||||
}
|
||||
printf("Input baud rate changed to %d\n", (int)cfgetispeed(&newtio));
|
||||
@@ -921,21 +927,24 @@ bool dlmstp_init(void *poPort, char *ifname)
|
||||
|
||||
/* Assert Data Terminal Ready (DTR) */
|
||||
if (ioctl(poSharedData->RS485_Handle, TIOCSDTR) == -1) {
|
||||
printf("Error asserting DTR %s - %s(%d).\n", poSharedData->RS485_Port_Name, strerror(errno),
|
||||
errno);
|
||||
printf(
|
||||
"Error asserting DTR %s - %s(%d).\n", poSharedData->RS485_Port_Name,
|
||||
strerror(errno), errno);
|
||||
}
|
||||
|
||||
/* Clear Data Terminal Ready (DTR) */
|
||||
if (ioctl(poSharedData->RS485_Handle, TIOCCDTR) == -1) {
|
||||
printf("Error clearing DTR %s - %s(%d).\n", poSharedData->RS485_Port_Name, strerror(errno),
|
||||
errno);
|
||||
printf(
|
||||
"Error clearing DTR %s - %s(%d).\n", poSharedData->RS485_Port_Name,
|
||||
strerror(errno), errno);
|
||||
}
|
||||
|
||||
/* Set the modem lines depending on the bits set in handshake */
|
||||
handshake = TIOCM_DTR | TIOCM_RTS | TIOCM_CTS | TIOCM_DSR;
|
||||
if (ioctl(poSharedData->RS485_Handle, TIOCMSET, &handshake) == -1) {
|
||||
printf("Error setting handshake lines %s - %s(%d).\n", poSharedData->RS485_Port_Name,
|
||||
strerror(errno), errno);
|
||||
printf(
|
||||
"Error setting handshake lines %s - %s(%d).\n",
|
||||
poSharedData->RS485_Port_Name, strerror(errno), errno);
|
||||
}
|
||||
|
||||
/* To read the state of the modem lines, use the following ioctl.
|
||||
@@ -944,16 +953,18 @@ bool dlmstp_init(void *poPort, char *ifname)
|
||||
|
||||
/* Store the state of the modem lines in handshake */
|
||||
if (ioctl(poSharedData->RS485_Handle, TIOCMGET, &handshake) == -1) {
|
||||
printf("Error getting handshake lines %s - %s(%d).\n", poSharedData->RS485_Port_Name,
|
||||
strerror(errno), errno);
|
||||
printf(
|
||||
"Error getting handshake lines %s - %s(%d).\n",
|
||||
poSharedData->RS485_Port_Name, strerror(errno), errno);
|
||||
}
|
||||
|
||||
printf("Handshake lines currently set to %d\n", handshake);
|
||||
|
||||
if (ioctl(poSharedData->RS485_Handle, IOSSDATALAT, &mics) == -1) {
|
||||
/* set latency to 1 microsecond */
|
||||
printf("Error setting read latency %s - %s(%d).\n", poSharedData->RS485_Port_Name,
|
||||
strerror(errno), errno);
|
||||
printf(
|
||||
"Error setting read latency %s - %s(%d).\n",
|
||||
poSharedData->RS485_Port_Name, strerror(errno), errno);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user