diff --git a/CMakeLists.txt b/CMakeLists.txt index 76b1100..391b1f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,10 +57,8 @@ target_include_directories(${PROJECT_NAME} PUBLIC ${LIBUSB_INCLUDE_DIRS}) target_link_libraries(${PROJECT_NAME} ${LIBUSB_LIBRARIES}) if(WIN32) target_link_libraries(${PROJECT_NAME} libpthread.a) - target_compile_options(${PROJECT_NAME} PRIVATE -Wall -O2 -static-libgcc -fno-strict-aliasing) -else() - target_compile_options(${PROJECT_NAME} PRIVATE -Wall -O2 -fno-strict-aliasing) endif(WIN32) +target_compile_options(${PROJECT_NAME} PRIVATE -Wall -O2 -fno-strict-aliasing) install(TARGETS ${PROJECT_NAME} DESTINATION lib) install(FILES ./eismultiplexer.h DESTINATION include) diff --git a/eismultiplexer.c b/eismultiplexer.c index b960541..08477fa 100644 --- a/eismultiplexer.c +++ b/eismultiplexer.c @@ -230,7 +230,7 @@ int eismultiplexer_wait_trigger(struct eismultiplexer* muliplexer, uint16_t inde int eismultiplexer_get_trigger_count(struct eismultiplexer* muliplexer) { uint8_t buffer[1] = {}; - int ret = usbshm_read_control_transfer(muliplexer->priv, COMMAND_GET_TRIG_COUNT, 0, 0, buffer, 1); + int ret = usbshm_read_control_transfer(muliplexer->priv, COMMAND_GET_TRIG, 0, 0, buffer, 1); if(ret >= 0) return buffer[0]; else diff --git a/eismultiplexer.h b/eismultiplexer.h index 7fa36d6..e5cb1ef 100644 --- a/eismultiplexer.h +++ b/eismultiplexer.h @@ -28,7 +28,7 @@ #pragma once #include -#include +#include #include /** diff --git a/main.c b/main.c index 7c9eb31..62fc29f 100644 --- a/main.c +++ b/main.c @@ -81,7 +81,6 @@ void print_commands(void) puts("read [ADDRESS] [LENGTH]\t | read from the device eeprom at address"); puts("write [ADDRESS] [LENGTH] | write to the device eeprom at address"); puts("trigger [INDEX] [STATE]\t | set the trigger state input (0), output and low (1) or output and high(2)"); - puts("wait [INDEX] [TYPE]\t | wait for an input trigger event"); puts("list\t\t\t | list the serial nummbers of the connected devices"); puts("channels\t\t | get the number of channels the device has"); } @@ -156,15 +155,8 @@ static int process_commands(char** commands, size_t command_count, struct eismul } else if(strcmp(commands[0], "get") == 0) { - uint16_t count; - int ret = eismultiplexer_get_channel_count(multiplexer, &count); - if(ret < 0) - { - printf("could not get the number of channels\n"); - return 3; - } channel_t channels = eismultiplexer_get_connected(multiplexer); - for(size_t i = 0; i < count; ++i) + for(size_t i = 0; i < 7; ++i) { bool connected = channels & (1 << i); printf("Channel %c: %s\n", (char)('A'+i), connected ? "on" : "off"); @@ -231,39 +223,6 @@ static int process_commands(char** commands, size_t command_count, struct eismul return 3; } } - else if(strcmp(commands[0], "wait") == 0) - { - if(command_count < 2) - { - printf("Usage %s %s [INDEX] [TYPE]\n", name, commands[0]); - puts("Type is one of:"); - puts("0: Waits until the trigger falls from high to low"); - puts("1: Waits until the trigger rises from low to high"); - puts("2: Waits until the trigger changes from low to high or high to low"); - puts("3: Waits until the trigger is low"); - puts("4: Waits until the trigger is high"); - return 2; - } - int trigger_count = eismultiplexer_get_trigger_count(multiplexer); - long index = strtol(commands[1], NULL, 10); - long type = strtol(commands[2], NULL, 10); - if(type >= 5) - { - printf("%li is an invalid type\n", type); - return 2; - } - if(index >= trigger_count) - { - printf("%li is out of range as the device has only %i triggers\n", index, trigger_count); - return 2; - } - int ret = eismultiplexer_wait_trigger(multiplexer, index, type, 1000000000); - if(ret < 0) - { - puts("Unable to wait for trigger"); - return 3; - } - } else { if(command_count != 2) @@ -417,7 +376,9 @@ int main(int argc, char* argv[]) } else { + eismultiplexer_set_led(&multiplexer, true); ret = process_commands(config.commands, config.command_count, &multiplexer, argv[0]); + eismultiplexer_set_led(&multiplexer, false); } eismultiplexer_disconnect(&multiplexer);