MCPcopy Create free account
hub / github.com/Hamlib/Hamlib / ser_set_dtr

Function ser_set_dtr

src/serial.c:1173–1224  ·  view source on GitHub ↗

* \brief Set Data Terminal Ready (DTR) bit * \param p * \param state true/false * \return RIG_OK or < 0 */

Source from the content-addressed store, hash-verified

1171 * \return RIG_OK or < 0
1172 */
1173int HAMLIB_API ser_set_dtr(hamlib_port_t *p, int state)
1174{
1175 unsigned int y = TIOCM_DTR;
1176 int rc;
1177
1178 rig_debug(RIG_DEBUG_VERBOSE, "%s: DTR=%d\n", __func__, state);
1179
1180 // silently ignore on microHam RADIO channel,
1181 // but (un)set ptt on microHam PTT channel.
1182 if (p->fd == uh_radio_fd)
1183 {
1184 return (RIG_OK);
1185 }
1186
1187 if (p->fd == uh_ptt_fd)
1188 {
1189 uh_set_ptt(state);
1190 return (RIG_OK);
1191 }
1192
1193#if defined(TIOCMBIS) && defined(TIOCMBIC)
1194 rc = IOCTL(p->fd, state ? TIOCMBIS : TIOCMBIC, &y);
1195#else
1196 rc = IOCTL(p->fd, TIOCMGET, &y);
1197
1198 if (rc >= 0)
1199 {
1200 if (state)
1201 {
1202 y |= TIOCM_DTR;
1203 }
1204 else
1205 {
1206 y &= ~TIOCM_DTR;
1207 }
1208
1209 rc = IOCTL(p->fd, TIOCMSET, &y);
1210 }
1211
1212#endif
1213
1214 if (rc < 0)
1215 {
1216 rig_debug(RIG_DEBUG_ERR,
1217 "%s: Cannot change DTR - %s\n",
1218 __func__,
1219 strerror(errno));
1220 return (-RIG_EIO);
1221 }
1222
1223 return (RIG_OK);
1224}
1225
1226
1227/**

Callers 10

simplecat_openFunction · 0.85
ad_fsyncFunction · 0.85
ad_ioupdFunction · 0.85
rshfiq_openFunction · 0.85
rot_openFunction · 0.85
rig_openFunction · 0.85
rig_closeFunction · 0.85
rig_set_pttFunction · 0.85
port_openFunction · 0.85
amp_openFunction · 0.85

Calls 2

rig_debugFunction · 0.85
uh_set_pttFunction · 0.85

Tested by

no test coverage detected