|
| 1 | +# KRT2-controller |
| 2 | +This is a simple linux library for communicating with KRT2 radios by TQ-Group |
| 3 | +To use it, include files in 'src' folder in your project |
| 4 | + |
| 5 | +## Initializing the library |
| 6 | +To initialize library first allocate memory for following data: |
| 7 | +- `struct KRT2_frequency` |
| 8 | +- `struct KRT2_communication` |
| 9 | +- `char status` |
| 10 | +- `char error` |
| 11 | + |
| 12 | +after that call `krt_init()` and set: |
| 13 | +- `char* file` to serial port file |
| 14 | +- rest of the arguments as pointers to previously allocated data |
| 15 | + |
| 16 | +**Remember to check for faults!** |
| 17 | + |
| 18 | +Example: |
| 19 | +```C |
| 20 | +struct KRT2_frequency frequency; |
| 21 | +struct KRT2_communication communication; |
| 22 | +char status; |
| 23 | +char error; |
| 24 | + |
| 25 | +int ret_val = krt_init("/dev/ttyS0", &frequency, &communication, &status, &error); |
| 26 | +if (ret_val < 0) { |
| 27 | + printf("KRT2 initialization failed"); |
| 28 | +} |
| 29 | +``` |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | +## Using the library |
| 34 | + |
| 35 | +while using the library you should call `krt_check()` to check for incoming transmissions from KRT2 radio |
| 36 | +`krt_check()` shouldn't be called less frequently than 50 ms |
| 37 | +when calling `krt_check()` check for any faults (returns -1) |
| 38 | + |
| 39 | +to send any commands to KRT2 radio use following functions: |
| 40 | +- `set_frequency()` to set active or standby frequency (and frequency name) |
| 41 | +- `set_new_communication_cfg()` to set volume, squelch or intercom (VOX) squelch |
| 42 | +- `set_PTT()` to set PTT button |
| 43 | +- `set_intercom_vol()` to set intercom (VOX) volume |
| 44 | +- `set_ext_audio_vol()` to set external audio input volume |
| 45 | +- `set_sidetone()` to set sidetone |
| 46 | +- `set_spacing()` to set channel spacing (8.33 kHz or 25 kHz) |
| 47 | + |
| 48 | +for more detail check function comments |
| 49 | + |
| 50 | +to get data about current radio status read `KRT2_frequency` and `KRT2_communication` structs |
| 51 | +or `status` and `error` chars (To decypher them use _MASKs defined in `krt2-ctrl.h`) |
| 52 | + |
| 53 | +## Example useage |
| 54 | + |
| 55 | +To see example program check `test.c` in `/test` folder |
| 56 | + |
| 57 | +## Milestones: |
| 58 | + |
| 59 | +- [x] Handle incoming data from KRT2 radio |
| 60 | +- [x] Allow to send commands to KRT2 radio |
| 61 | +- [x] Create example program |
| 62 | +- [ ] Remove need to call `krt_check` manually |
| 63 | +- [ ] Add support for receive only commands in KRT2 radio |
0 commit comments