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

Function parseFrame

src/microham.c:392–499  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

390static int numcontrolbytes = 0;
391
392static void parseFrame(const unsigned char *frame)
393{
394 unsigned char byte;
395 FRAME("RCV frame %02x %02x %02x %02x\n", frame[0], frame[1], frame[2],
396 frame[3]);
397
398 // frames come in sequences. The first frame of a sequence has bit6 cleared in the headerbyte.
399 if ((frame[0] & 0x40) == 0)
400 {
401 frameseq = 0;
402 }
403 else
404 {
405 frameseq++;
406 }
407
408 // A frame is of the form header-byte1-byte2-byte3
409 // byte 1 is always RADIO, byte 2 is always RADIO2/AUX (if validity bit set)
410 // byte 3 has different meaning, depending on the sequence number of the frame:
411 // seq=0 -> Flags
412 // seq=1 -> control
413 // seq=2 -> WinKey
414 // seq=3 -> PS2
415
416 // if RADIO byte is valid, send it to client
417 if ((frame[0] & 0x20) != 0)
418 {
419 byte = frame[1] & 0x7F;
420
421 if ((frame[0] & 0x04) != 0)
422 {
423 byte |= 0x80;
424 }
425
426 DEBUG("%10d:FromRadio: %02x\n", TIME, byte);
427
428 if (write(uh_radio_pair[0], &byte, 1) != 1)
429 {
430 MYERROR("Write Radio Socket\n");
431 }
432 }
433
434 // ignore AUX/RADIO2 for the time being
435
436 // check the shared channel for validity, if it is the CONTROL channel it is always valid
437 if ((frame[0] & 0x08) || (frameseq == 1))
438 {
439 byte = frame[3] & 0x7F;
440
441 if (frame[0] & 0x01)
442 {
443 byte |= 0x80;
444 }
445
446 switch (frameseq)
447 {
448 case 0: // Flag byte
449 DEBUG("%10d:RCV: Flags=%02x\n", TIME, byte);

Callers 1

read_deviceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected