diff --git a/embedded/mkrouter-v06/.vs/mkrouter-v06/v14/.atsuo b/embedded/mkrouter-v06/.vs/mkrouter-v06/v14/.atsuo index 9b391be6e8abd8e75ad0de9023f8a214455cb1e2..2493d226405116c878087141465236d67614cd02 100644 Binary files a/embedded/mkrouter-v06/.vs/mkrouter-v06/v14/.atsuo and b/embedded/mkrouter-v06/.vs/mkrouter-v06/v14/.atsuo differ diff --git a/embedded/mkrouter-v06/mkrouter-v06/Debug/Makefile b/embedded/mkrouter-v06/mkrouter-v06/Debug/Makefile index a75817b9ed0b13c8757e030a1d33611c922a4c76..f44e3128ec277297ee7b0f3003823f18bc5f1c96 100644 --- a/embedded/mkrouter-v06/mkrouter-v06/Debug/Makefile +++ b/embedded/mkrouter-v06/mkrouter-v06/Debug/Makefile @@ -38,7 +38,6 @@ SUBDIRS := \ # Add inputs and outputs from these tool invocations to the build variables C_SRCS += \ -../apahandler.c \ ../apaport.c \ ../board_driver_serial.c \ ../board_driver_usb.c \ @@ -62,7 +61,6 @@ ASM_SRCS += OBJS += \ -apahandler.o \ apaport.o \ board_driver_serial.o \ board_driver_usb.o \ @@ -79,7 +77,6 @@ sam_ba_usb.o \ uartport.o OBJS_AS_ARGS += \ -apahandler.o \ apaport.o \ board_driver_serial.o \ board_driver_usb.o \ @@ -96,7 +93,6 @@ sam_ba_usb.o \ uartport.o C_DEPS += \ -apahandler.d \ apaport.d \ board_driver_serial.d \ board_driver_usb.d \ @@ -113,7 +109,6 @@ sam_ba_usb.d \ uartport.d C_DEPS_AS_ARGS += \ -apahandler.d \ apaport.d \ board_driver_serial.d \ board_driver_usb.d \ @@ -171,8 +166,6 @@ LINKER_SCRIPT_DEP+= \ - - diff --git a/embedded/mkrouter-v06/mkrouter-v06/Debug/makedep.mk b/embedded/mkrouter-v06/mkrouter-v06/Debug/makedep.mk index 3d40a921a8e2f7feeb61ecf356b10268698db769..1915db9add930792ff74f84752f48a63feac5dce 100644 --- a/embedded/mkrouter-v06/mkrouter-v06/Debug/makedep.mk +++ b/embedded/mkrouter-v06/mkrouter-v06/Debug/makedep.mk @@ -2,8 +2,6 @@ # Automatically-generated file. Do not edit or delete the file ################################################################################ -apahandler.c - apaport.c board_driver_serial.c diff --git a/embedded/mkrouter-v06/mkrouter-v06/apahandler.c b/embedded/mkrouter-v06/mkrouter-v06/apahandler.c index b30b07d53111afe36dd01312887654a540784987..89a74e899b6eeea6aa1b2cbaa797dce2d1c15a0a 100644 --- a/embedded/mkrouter-v06/mkrouter-v06/apahandler.c +++ b/embedded/mkrouter-v06/mkrouter-v06/apahandler.c @@ -11,7 +11,10 @@ void apa_handle_packet(uint8_t *packet, uint8_t length){ // dirty debug reply + //sam_ba_port_put_data(packet, packet[0]); + // through packet + int i = 0; int apa_handler_state = APA_HANDLER_OUTSIDE; diff --git a/embedded/mkrouter-v06/mkrouter-v06/apahandler.h b/embedded/mkrouter-v06/mkrouter-v06/apahandler.h deleted file mode 100644 index 32c7104a4ef2549c51740733681ddcd109d16e5b..0000000000000000000000000000000000000000 --- a/embedded/mkrouter-v06/mkrouter-v06/apahandler.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * apahandler.h - * - * Created: 3/12/2018 11:55:40 AM - * Author: Jake - */ - - -#ifndef APAHANDLER_H_ -#define APAHANDLER_H_ - -#include "sam.h" - -#define APA_HANDLER_OUTSIDE 0 -#define APA_HANDLER_INSIDE 1 - -#define DELIM_KEY_TEST 127 // toggles a light, to test network -#define DELIM_KEY_STEPS 128 // steps (steps) uint32_t, speed (steps/s) uint32_t, dir uint8_t -#define DELIM_KEY_BLOCK 129 // is 32 bit int - -void apa_handle_packet(uint8_t *packet, uint8_t length); -void apa_return_packet(uint8_t *packet, uint8_t length); - -#endif /* APAHANDLER_H_ */ \ No newline at end of file diff --git a/embedded/mkrouter-v06/mkrouter-v06/apaport.c b/embedded/mkrouter-v06/mkrouter-v06/apaport.c index 12ea6011197dd51fff257d926a13ad6663042218..454d08a21084c42b3e0e9261f12ae417f3f4255b 100644 --- a/embedded/mkrouter-v06/mkrouter-v06/apaport.c +++ b/embedded/mkrouter-v06/mkrouter-v06/apaport.c @@ -64,7 +64,9 @@ void apaport_scan(apaport_t *apap, uint32_t maxpackets){ // now to handle // [p][0] is length of packet if(apap->packets[p][1] == APA_ROUTE_POINTER){ - apa_handle_packet(apap->packets[p], apap->packets[p][0]); + pin_set(&stlPacket); + sam_ba_port_put_data(apap->packets[p], apap->packets[p][0]); + //apa_handle_packet(apap->packets[p], apap->packets[p][0]); } else if(apap->packets[p][1] == APA_ROUTE_FLOOD){ // loop through bytes to find pointer and increment // now ship it out on all ports diff --git a/embedded/mkrouter-v06/mkrouter-v06/apaport.h b/embedded/mkrouter-v06/mkrouter-v06/apaport.h index 60651f0dd7a7ebcd38c2d5c0548b119c1a0eacb7..7d16e3af91b5c6d7c15e87f7928c12268be17f50 100644 --- a/embedded/mkrouter-v06/mkrouter-v06/apaport.h +++ b/embedded/mkrouter-v06/mkrouter-v06/apaport.h @@ -9,7 +9,6 @@ #ifndef APAPORT_H_ #define APAPORT_H_ -#include "apahandler.h" #include "uartport.h" #include "pin.h" diff --git a/embedded/mkrouter-v06/mkrouter-v06/hardware.h b/embedded/mkrouter-v06/mkrouter-v06/hardware.h index 8ed7671397c35cdcd683f2438a6cddc925f09c5b..23f217561cbc62eadaad60e6b9705036ff3b78ff 100644 --- a/embedded/mkrouter-v06/mkrouter-v06/hardware.h +++ b/embedded/mkrouter-v06/mkrouter-v06/hardware.h @@ -16,6 +16,8 @@ #include "uartport.h" #include "apaport.h" +#include "sam_ba_monitor.h" + // For if-case init #define HARDWARE_IS_APBA 0 diff --git a/embedded/mkrouter-v06/mkrouter-v06/mkrouter-v06.cproj b/embedded/mkrouter-v06/mkrouter-v06/mkrouter-v06.cproj index 63d23678dabc68c446156e5664162bd41f5e2771..bec32ff91cb20918f1f8e783710233ea1cc20d9b 100644 --- a/embedded/mkrouter-v06/mkrouter-v06/mkrouter-v06.cproj +++ b/embedded/mkrouter-v06/mkrouter-v06/mkrouter-v06.cproj @@ -159,12 +159,6 @@ </ToolchainSettings> </PropertyGroup> <ItemGroup> - <Compile Include="apahandler.c"> - <SubType>compile</SubType> - </Compile> - <Compile Include="apahandler.h"> - <SubType>compile</SubType> - </Compile> <Compile Include="apaport.c"> <SubType>compile</SubType> </Compile> diff --git a/embedded/mkrouter-v06/mkrouter-v06/sam_ba_monitor.c b/embedded/mkrouter-v06/mkrouter-v06/sam_ba_monitor.c index c5c486988050a9609319f8893ef35f3242664f27..8e399a938f348fae2cb06c5e15997ad21e2091e0 100644 --- a/embedded/mkrouter-v06/mkrouter-v06/sam_ba_monitor.c +++ b/embedded/mkrouter-v06/mkrouter-v06/sam_ba_monitor.c @@ -273,26 +273,58 @@ static void put_uint32(uint32_t n) } uint32_t tick = 0; -uint8_t data_out[3] = {12, 48, 64}; +uint8_t data_out[3] = {12, 48, 64}; + +#define APA_CDC_NUM_STATIC_PACKETS 6 +uint8_t packCDC[APA_CDC_NUM_STATIC_PACKETS][256]; // static memory buffer for packets +uint8_t packCDC_num = 0; +uint8_t packCDC_position = 0; +uint8_t packCDC_readyNum = 0; static void sam_ba_monitor_loop(void) { // get bytes, handle.. length = sam_ba_getdata(ptr_monitor_if, data, SIZEBUFMAX); - pin_clear(&stlPacket); + // this should be better: but before we send we have to make sure COM is open, else port locked if(length > 0 && !usbComOpen){ usbComOpen = 1; pin_clear(&stlUsb); + uint8_t hello[2] = {0,0}; + sam_ba_putdata(ptr_monitor_if, &hello, 2); + return; + } + + // chunk packets into packCDC + if(length > 0 && usbComOpen){ + pin_clear(&stlPacket); + for(int i = 0; i < length; i ++){ + packCDC[packCDC_num][packCDC_position] = data[i]; + packCDC_position ++; + if(packCDC_position >= packCDC[packCDC_num][0]){ + packCDC_num = (packCDC_num + 1) % APA_CDC_NUM_STATIC_PACKETS; + packCDC_readyNum ++; + packCDC_position = 0; + } + } } - // reply - sam_ba_putdata(ptr_monitor_if, data, length); + // handle all of the ready packets + while(packCDC_readyNum > 0){ + uint8_t p = (packCDC_num + APA_CDC_NUM_STATIC_PACKETS - packCDC_readyNum) % APA_CDC_NUM_STATIC_PACKETS; + // we're going to forward them all, 1st byte is port out + uint8_t port = packCDC[p][1]; + if(port > NUM_UPS){ + port = NUM_UPS - 1; // if overrun, go on last port + } + uart_sendchars_buffered(ups[port], packCDC[p], packCDC[p][0]); + packCDC_readyNum --; + } + + // reply USB direct to debug if USB coming thru + // sam_ba_putdata(ptr_monitor_if, data, length); // have to implement APA code here? and watch for multipackets? - for(int i = 0; i < length; i ++, ptr++){ - // apa - } pin_set(&stlPacket); // dirt nasty heartbeat