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

Function uh_open_radio

src/microham.c:1165–1217  ·  view source on GitHub ↗

Number of stop bits must be 1 or 2. Number of data bits can be 5,6,7,8 Hardware handshake (rtscts) can be on of off. microHam devices ALWAYS use "no parity".

Source from the content-addressed store, hash-verified

1163// microHam devices ALWAYS use "no parity".
1164//
1165int uh_open_radio(int baud, int databits, int stopbits, int rtscts)
1166{
1167 unsigned char string[5];
1168 int baudrateConst;
1169
1170 if (!uh_is_initialized)
1171 {
1172 start_thread();
1173
1174 if (!uh_is_initialized)
1175 {
1176 return -1;
1177 }
1178 }
1179
1180 baudrateConst = 11059200 / baud ;
1181 string[0] = 0x01;
1182 string[1] = baudrateConst & 0xff ;
1183 string[2] = baudrateConst / 256 ;
1184
1185 switch (stopbits)
1186 {
1187 case 1: string[3] = 0x00; break;
1188
1189 case 2: string[3] = 0x40; break;
1190
1191 default: return -1;
1192 }
1193
1194 if (rtscts)
1195 {
1196 string[3] |= 0x10;
1197 }
1198
1199 switch (databits)
1200 {
1201 case 5: break;
1202
1203 case 6: string[3] |= 0x20; break;
1204
1205 case 7: string[3] |= 0x40; break;
1206
1207 case 8: string[3] |= 0x60; break;
1208
1209 default: return -1;
1210 }
1211
1212 string[4] = 0x81;
1213 writeControl(string, 5);
1214
1215 uh_radio_in_use = 1;
1216 return uh_radio_pair[1];
1217}
1218
1219
1220void uh_set_ptt(int ptt)

Callers 1

serial_openFunction · 0.85

Calls 2

writeControlFunction · 0.85
start_threadFunction · 0.70

Tested by

no test coverage detected