]> git.defcon.no Git - hm-trp-tool/blob - read_hm-trp.c
I forgot, all source needs README and licensing
[hm-trp-tool] / read_hm-trp.c
1 #include <errno.h> /* Error number definitions */
2 #include <string.h> /* String function definitions */
3 #include <stdio.h> /* Standard I/O */
4 #include <unistd.h> /* sleep */
5 #include <stdlib.h> /* malloc, free */
6
7 #include "hm-trp.h"
8 #include "serial.h"
9
10 #define CBUFFER_SIZE 32
11
12 int main ( int argc, char** argv )
13 {
14 int fd;
15 int res;
16 int r, c, f;
17 unsigned char buf[CBUFFER_SIZE];
18
19 config_t* config = malloc(sizeof(config_t));
20 bzero(config, sizeof(config_t));
21
22 if ( ! argv[1] )
23 {
24 printf("Serial port device required as argument, e.g. /dev/ttyUSB0\n");
25 return 1;
26 }
27
28
29 printf("Looking for device on port %s\n", argv[1]);
30
31 for ( r = 0; r <= count_rates; r++ )
32 {
33 fd = open_port( argv[1], port_rates[r] );
34 if ( fd < 0 )
35 {
36 perror(argv[1]);
37 return(-1);
38 }
39
40 if ( read_config( fd, config ) == 1 )
41 {
42 printf("Found device at baud-rate %d, config:\n", port_rate_value[r] );
43 printf("Freq %d \n", config->freq );
44 printf("Air rate %d \n", config->air_rate );
45 printf("Deviation %d \n", config->deviation );
46 printf("TX Power %d \n", config->power );
47 printf("BW %d \n", config->bw );
48 printf("UART rate %d \n", config->uart_rate );
49
50
51 for ( f = 0; f < count_devtype; f++ )
52 {
53 if ( (config->freq >= freq_min[f]) &&
54 (config->freq <= freq_max[f]))
55 {
56 printf("Device type is %s\n", dev_name[f]);
57 }
58 }
59
60 return(0);
61 }
62 close(fd);
63 }
64 printf("Unable to find device on %s\n", argv[1]);
65 return(1);
66 }
67