From 167ebe9be8e7cf1bf403dbeb017267e9a188f439 Mon Sep 17 00:00:00 2001 From: Jon Langseth Date: Mon, 9 Jul 2012 23:51:57 +0200 Subject: [PATCH] Cleaning up a bit. set_speed no longer needed, QT-Tool does the job better. --- build.sh | 2 -- set_speed.c | 85 -------------------------------------------------- swap.c_example | 19 ----------- 3 files changed, 106 deletions(-) delete mode 100644 set_speed.c delete mode 100644 swap.c_example diff --git a/build.sh b/build.sh index 21cc481..8c2c694 100755 --- a/build.sh +++ b/build.sh @@ -7,5 +7,3 @@ do done gcc read_hm-trp.o hm-trp.o serial.o -o read_hm-trp -gcc set_speed.o hm-trp.o serial.o -o set_speed - diff --git a/set_speed.c b/set_speed.c deleted file mode 100644 index c29393c..0000000 --- a/set_speed.c +++ /dev/null @@ -1,85 +0,0 @@ -#include /* Error number definitions */ -#include /* String function definitions */ -#include /* Standard I/O */ -#include /* sleep */ -#include /* malloc, free */ - -#include "hm-trp.h" -#include "serial.h" - -#define CBUFFER_SIZE 32 - -int main ( int argc, char** argv ) -{ - int fd; - int res; - int r, c, f; - long rate; - - unsigned char buf[CBUFFER_SIZE]; - - config_t* config = malloc(sizeof(config_t)); - bzero(config, sizeof(config_t)); - - if ( ! argv[1] ) - { - printf("Serial port device required as argument, e.g. /dev/ttyUSB0\n"); - return 1; - } - - if ( ! argv[2] ) - { - printf("Desired bit-rate required. Use RS232 rates only.\n"); - return 1; - } - - rate = atol( argv[2] ); - for ( r = 0; r <= count_rates; r++ ) - if ( port_rate_value[r] == rate ) { rate = r; break; } - - if ( r >= count_rates ) { printf("Invalid data rate requested\n"); return 1; } - - printf("Looking for device on port %s\n", argv[1]); - - for ( r = 0; r <= count_rates; r++ ) - { - fd = open_port( argv[1], port_rates[r] ); - if ( fd < 0 ) - { - perror(argv[1]); - return(-1); - } - - if ( read_config( fd, config ) == 1 ) - { - printf("Found device at baud-rate %d.\n", port_rate_value[r] ); - - if ( r == rate && ( config->air_rate == config->uart_rate ) ) - { - printf("Data rate is already set to %d\n", port_rate_value[r] ); - return 0; - } - - write_cmd( fd, cmd_air_rate ); - write_uint32_t( fd, port_rate_value[rate] ); - - if ( ! read_ok( fd ) ) - { - printf("Air rate NOT set\n"); - return 1; - } - - write_cmd( fd, cmd_uart_rate ); - write_uint32_t( fd, port_rate_value[rate] ); - - read_ok( fd ); // Clear buffer. - - printf("Device UART and air data rate set to %d\n", port_rate_value[rate] ); - return(0); - } - close(fd); - } - printf("Unable to find device on %s\n", argv[1]); - return(1); -} - diff --git a/swap.c_example b/swap.c_example deleted file mode 100644 index 401f53a..0000000 --- a/swap.c_example +++ /dev/null @@ -1,19 +0,0 @@ -#include /* __bwap_{16,32} */ - -/* - Basically, does: -uint32_t swap_uint32 ( uint32_t num ) -{ - return ( (num>>24) & 0x000000ff) | // move byte 3 to byte 0 - ( (num<<8) & 0x00ff0000) | // move byte 1 to byte 2 - ( (num>>8) & 0x0000ff00) | // move byte 2 to byte 1 - ( (num<<24) & 0xff000000); // byte 0 to byte 3 -} - -uint16_t swap_uint16 ( uint16_t num ) -{ - // Move UP and mask | Move DOWN and mask - return( (num<<8) & 0xff00 ) | ( (num>>8) & 0x00ff ); -} -*/ - -- 2.39.2