* Build a CI-V frame. * The whole frame is placed in frame[], * "re_id" is the transceiver's CI-V address, * "cmd" is the Command number, * "subcmd" is the Sub command number, set to -1 if not present in frame, * if the frame has no data, then the "data" pointer must be NULL, * and data_len==0. * "data_len" holds the Data area length pointed by the "data" pointer. * REM: if "data" is
| 49 | * The smallest frame is 6 bytes, the biggest is at least 13 bytes. |
| 50 | */ |
| 51 | int make_cmd_frame(unsigned char frame[], unsigned char re_id, |
| 52 | unsigned char ctrl_id, |
| 53 | unsigned char cmd, int subcmd, |
| 54 | const unsigned char *data, int data_len) |
| 55 | { |
| 56 | int i = 0; |
| 57 | |
| 58 | #if 0 |
| 59 | frame[i++] = PAD; /* give old rigs a chance to flush their rx buffers */ |
| 60 | #endif |
| 61 | frame[i++] = PR; /* Preamble code */ |
| 62 | frame[i++] = PR; |
| 63 | frame[i++] = re_id; |
| 64 | frame[i++] = ctrl_id; |
| 65 | frame[i++] = cmd; |
| 66 | |
| 67 | if (subcmd != -1) |
| 68 | { |
| 69 | #ifdef MULTIB_SUBCMD |
| 70 | register int j; |
| 71 | |
| 72 | if ((j = subcmd & 0xff0000)) /* allows multi-byte subcmd for dsp rigs */ |
| 73 | { |
| 74 | frame[i++] = j >> 16; |
| 75 | frame[i++] = (subcmd & 0xff00) >> 8; |
| 76 | } |
| 77 | else if ((j = subcmd & 0xff00)) { frame[i++] = j >> 8; } |
| 78 | |
| 79 | #endif |
| 80 | frame[i++] = subcmd & 0xff; |
| 81 | } |
| 82 | |
| 83 | if (data_len != 0) |
| 84 | { |
| 85 | memcpy(frame + i, data, data_len); |
| 86 | i += data_len; |
| 87 | } |
| 88 | |
| 89 | frame[i++] = FI; /* EOM code */ |
| 90 | |
| 91 | return (i); |
| 92 | } |
| 93 | |
| 94 | int icom_frame_fix_preamble(int frame_len, unsigned char *frame) |
| 95 | { |
no outgoing calls
no test coverage detected