diff --git a/.gitignore b/.gitignore index 13e79f3..9f68a32 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ -UnitFirmware/module_rev0/build/* -UnitFirmware/module_rev0/build -Server/build/* -Server/build -ModuleController/ModuleController-backups/* -ModuleController/ModuleController-backups \ No newline at end of file +software/firmware_module/module_rev0/build/* +software/firmware_module/module_rev0/build +software/pc_client/build/* +software/pc_client/build +hardware/module_controller/ModuleController-backups/* +hardware/module_controller/ModuleController-backups +hardware/module_controller/~*.lck \ No newline at end of file diff --git a/README.md b/README.md index 3fe3892..5c30edb 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Notable changes: * Hot-swappable modules * New Backplane * New PCB, using mostly smd components and an atmega8 mcu. -* RS-485 bus +* RS-485 at 19200-Baud, Half-Duplex * Custom leightweight protocol * Controller, running an WebSockets-Server. * Homing-Failure and overcurrent detection diff --git a/buildtools/git-hook.sh b/buildtools/git-hook.sh new file mode 100644 index 0000000..e69de29 diff --git a/ModuleController/GBR/GBR.zip b/hardware/module_controller/GBR/GBR.zip similarity index 100% rename from ModuleController/GBR/GBR.zip rename to hardware/module_controller/GBR/GBR.zip diff --git a/ModuleController/GBR/ModuleController-B_Cu.gbr b/hardware/module_controller/GBR/ModuleController-B_Cu.gbr similarity index 100% rename from ModuleController/GBR/ModuleController-B_Cu.gbr rename to hardware/module_controller/GBR/ModuleController-B_Cu.gbr diff --git a/ModuleController/GBR/ModuleController-B_Mask.gbr b/hardware/module_controller/GBR/ModuleController-B_Mask.gbr similarity index 100% rename from ModuleController/GBR/ModuleController-B_Mask.gbr rename to hardware/module_controller/GBR/ModuleController-B_Mask.gbr diff --git a/ModuleController/GBR/ModuleController-B_Paste.gbr b/hardware/module_controller/GBR/ModuleController-B_Paste.gbr similarity index 100% rename from ModuleController/GBR/ModuleController-B_Paste.gbr rename to hardware/module_controller/GBR/ModuleController-B_Paste.gbr diff --git a/ModuleController/GBR/ModuleController-B_Silkscreen.gbr b/hardware/module_controller/GBR/ModuleController-B_Silkscreen.gbr similarity index 100% rename from ModuleController/GBR/ModuleController-B_Silkscreen.gbr rename to hardware/module_controller/GBR/ModuleController-B_Silkscreen.gbr diff --git a/ModuleController/GBR/ModuleController-Edge_Cuts.gbr b/hardware/module_controller/GBR/ModuleController-Edge_Cuts.gbr similarity index 100% rename from ModuleController/GBR/ModuleController-Edge_Cuts.gbr rename to hardware/module_controller/GBR/ModuleController-Edge_Cuts.gbr diff --git a/ModuleController/GBR/ModuleController-F_Cu.gbr b/hardware/module_controller/GBR/ModuleController-F_Cu.gbr similarity index 100% rename from ModuleController/GBR/ModuleController-F_Cu.gbr rename to hardware/module_controller/GBR/ModuleController-F_Cu.gbr diff --git a/ModuleController/GBR/ModuleController-F_Mask.gbr b/hardware/module_controller/GBR/ModuleController-F_Mask.gbr similarity index 100% rename from ModuleController/GBR/ModuleController-F_Mask.gbr rename to hardware/module_controller/GBR/ModuleController-F_Mask.gbr diff --git a/ModuleController/GBR/ModuleController-F_Paste.gbr b/hardware/module_controller/GBR/ModuleController-F_Paste.gbr similarity index 100% rename from ModuleController/GBR/ModuleController-F_Paste.gbr rename to hardware/module_controller/GBR/ModuleController-F_Paste.gbr diff --git a/ModuleController/GBR/ModuleController-F_Silkscreen.gbr b/hardware/module_controller/GBR/ModuleController-F_Silkscreen.gbr similarity index 100% rename from ModuleController/GBR/ModuleController-F_Silkscreen.gbr rename to hardware/module_controller/GBR/ModuleController-F_Silkscreen.gbr diff --git a/ModuleController/GBR/ModuleController-NPTH-drl_map.gbr b/hardware/module_controller/GBR/ModuleController-NPTH-drl_map.gbr similarity index 100% rename from ModuleController/GBR/ModuleController-NPTH-drl_map.gbr rename to hardware/module_controller/GBR/ModuleController-NPTH-drl_map.gbr diff --git a/ModuleController/GBR/ModuleController-NPTH.drl b/hardware/module_controller/GBR/ModuleController-NPTH.drl similarity index 100% rename from ModuleController/GBR/ModuleController-NPTH.drl rename to hardware/module_controller/GBR/ModuleController-NPTH.drl diff --git a/ModuleController/GBR/ModuleController-PTH-drl_map.gbr b/hardware/module_controller/GBR/ModuleController-PTH-drl_map.gbr similarity index 100% rename from ModuleController/GBR/ModuleController-PTH-drl_map.gbr rename to hardware/module_controller/GBR/ModuleController-PTH-drl_map.gbr diff --git a/ModuleController/GBR/ModuleController-PTH.drl b/hardware/module_controller/GBR/ModuleController-PTH.drl similarity index 100% rename from ModuleController/GBR/ModuleController-PTH.drl rename to hardware/module_controller/GBR/ModuleController-PTH.drl diff --git a/ModuleController/GBR/ModuleController-bottom-pos.csv b/hardware/module_controller/GBR/ModuleController-bottom-pos.csv similarity index 100% rename from ModuleController/GBR/ModuleController-bottom-pos.csv rename to hardware/module_controller/GBR/ModuleController-bottom-pos.csv diff --git a/ModuleController/GBR/ModuleController-bottom.pos b/hardware/module_controller/GBR/ModuleController-bottom.pos similarity index 100% rename from ModuleController/GBR/ModuleController-bottom.pos rename to hardware/module_controller/GBR/ModuleController-bottom.pos diff --git a/ModuleController/GBR/ModuleController-job.gbrjob b/hardware/module_controller/GBR/ModuleController-job.gbrjob similarity index 100% rename from ModuleController/GBR/ModuleController-job.gbrjob rename to hardware/module_controller/GBR/ModuleController-job.gbrjob diff --git a/ModuleController/GBR/ModuleController-top-pos.csv b/hardware/module_controller/GBR/ModuleController-top-pos.csv similarity index 100% rename from ModuleController/GBR/ModuleController-top-pos.csv rename to hardware/module_controller/GBR/ModuleController-top-pos.csv diff --git a/ModuleController/GBR/ModuleController-top.pos b/hardware/module_controller/GBR/ModuleController-top.pos similarity index 100% rename from ModuleController/GBR/ModuleController-top.pos rename to hardware/module_controller/GBR/ModuleController-top.pos diff --git a/ModuleController/GBR/ModuleController.csv b/hardware/module_controller/GBR/ModuleController.csv similarity index 100% rename from ModuleController/GBR/ModuleController.csv rename to hardware/module_controller/GBR/ModuleController.csv diff --git a/ModuleController/Module.step b/hardware/module_controller/Module.step similarity index 100% rename from ModuleController/Module.step rename to hardware/module_controller/Module.step diff --git a/ModuleController/ModuleController.kicad_pcb b/hardware/module_controller/ModuleController.kicad_pcb similarity index 100% rename from ModuleController/ModuleController.kicad_pcb rename to hardware/module_controller/ModuleController.kicad_pcb diff --git a/ModuleController/ModuleController.kicad_prl b/hardware/module_controller/ModuleController.kicad_prl similarity index 100% rename from ModuleController/ModuleController.kicad_prl rename to hardware/module_controller/ModuleController.kicad_prl diff --git a/ModuleController/ModuleController.kicad_pro b/hardware/module_controller/ModuleController.kicad_pro similarity index 100% rename from ModuleController/ModuleController.kicad_pro rename to hardware/module_controller/ModuleController.kicad_pro diff --git a/ModuleController/ModuleController.kicad_sch b/hardware/module_controller/ModuleController.kicad_sch similarity index 100% rename from ModuleController/ModuleController.kicad_sch rename to hardware/module_controller/ModuleController.kicad_sch diff --git a/ModuleController/ModuleController.step b/hardware/module_controller/ModuleController.step similarity index 100% rename from ModuleController/ModuleController.step rename to hardware/module_controller/ModuleController.step diff --git a/ModuleController/SplitFlap Improved v3.3mf b/hardware/module_controller/SplitFlap Improved v3.3mf similarity index 100% rename from ModuleController/SplitFlap Improved v3.3mf rename to hardware/module_controller/SplitFlap Improved v3.3mf diff --git a/ModuleController/SplitFlap Improved v5.3mf b/hardware/module_controller/SplitFlap Improved v5.3mf similarity index 100% rename from ModuleController/SplitFlap Improved v5.3mf rename to hardware/module_controller/SplitFlap Improved v5.3mf diff --git a/ModuleController/SplitFlap Improved v5.f3z b/hardware/module_controller/SplitFlap Improved v5.f3z similarity index 100% rename from ModuleController/SplitFlap Improved v5.f3z rename to hardware/module_controller/SplitFlap Improved v5.f3z diff --git a/ModuleController/SplitFlap Improved_Wheel.3mf b/hardware/module_controller/SplitFlap Improved_Wheel.3mf similarity index 100% rename from ModuleController/SplitFlap Improved_Wheel.3mf rename to hardware/module_controller/SplitFlap Improved_Wheel.3mf diff --git a/ModuleController/SplitFlap Improved_Wheelbase.f3z b/hardware/module_controller/SplitFlap Improved_Wheelbase.f3z similarity index 100% rename from ModuleController/SplitFlap Improved_Wheelbase.f3z rename to hardware/module_controller/SplitFlap Improved_Wheelbase.f3z diff --git a/ModuleController/fp-info-cache b/hardware/module_controller/fp-info-cache similarity index 100% rename from ModuleController/fp-info-cache rename to hardware/module_controller/fp-info-cache diff --git a/UnitFirmware/module_rev0/Makefile b/software/firmware_module/module_rev0/Makefile similarity index 100% rename from UnitFirmware/module_rev0/Makefile rename to software/firmware_module/module_rev0/Makefile diff --git a/UnitFirmware/module_rev0/src/main.c b/software/firmware_module/module_rev0/src/main.c similarity index 100% rename from UnitFirmware/module_rev0/src/main.c rename to software/firmware_module/module_rev0/src/main.c diff --git a/UnitFirmware/module_rev0/src/mctrl.c b/software/firmware_module/module_rev0/src/mctrl.c similarity index 100% rename from UnitFirmware/module_rev0/src/mctrl.c rename to software/firmware_module/module_rev0/src/mctrl.c diff --git a/UnitFirmware/module_rev0/src/mctrl.h b/software/firmware_module/module_rev0/src/mctrl.h similarity index 100% rename from UnitFirmware/module_rev0/src/mctrl.h rename to software/firmware_module/module_rev0/src/mctrl.h diff --git a/UnitFirmware/module_rev0/src/rcount.c b/software/firmware_module/module_rev0/src/rcount.c similarity index 100% rename from UnitFirmware/module_rev0/src/rcount.c rename to software/firmware_module/module_rev0/src/rcount.c diff --git a/UnitFirmware/module_rev0/src/rcount.h b/software/firmware_module/module_rev0/src/rcount.h similarity index 100% rename from UnitFirmware/module_rev0/src/rcount.h rename to software/firmware_module/module_rev0/src/rcount.h diff --git a/UnitFirmware/module_rev0/src/rs458.c b/software/firmware_module/module_rev0/src/rs458.c similarity index 100% rename from UnitFirmware/module_rev0/src/rs458.c rename to software/firmware_module/module_rev0/src/rs458.c diff --git a/UnitFirmware/module_rev0/src/rs485.h b/software/firmware_module/module_rev0/src/rs485.h similarity index 100% rename from UnitFirmware/module_rev0/src/rs485.h rename to software/firmware_module/module_rev0/src/rs485.h diff --git a/UnitFirmware/sketch_sep11a/sketch_sep11a.ino b/software/firmware_module/sketch_sep11a/sketch_sep11a.ino similarity index 100% rename from UnitFirmware/sketch_sep11a/sketch_sep11a.ino rename to software/firmware_module/sketch_sep11a/sketch_sep11a.ino diff --git a/Server/makefile b/software/pc_client/makefile similarity index 100% rename from Server/makefile rename to software/pc_client/makefile diff --git a/Server/src/devicemgr.c b/software/pc_client/src/devicemgr.c similarity index 65% rename from Server/src/devicemgr.c rename to software/pc_client/src/devicemgr.c index 792b855..cfc6562 100644 --- a/Server/src/devicemgr.c +++ b/software/pc_client/src/devicemgr.c @@ -1,4 +1,6 @@ #include "devicemgr.h" +#include +#include /* * This file provides an abstraction layer to access many devices @@ -8,26 +10,38 @@ enum SFDEVICE_STATE { NEW, OFFLINE, ONLINE, FAILED }; enum SFDEVICE_POWER { DISABLED, ENABLED, UNKNOWN }; struct SFDEVICE { - u_int16_t address; - int rs485_descriptor; - double reg_voltage; - u_int32_t reg_counter; - u_int8_t reg_status; - u_int8_t current_flap; - enum SFDEVICE_STATE deviceState; - enum SFDEVICE_POWER powerState; + int pos_x; + int pos_y; + u_int16_t address; + int rs485_descriptor; + double reg_voltage; + u_int32_t reg_counter; + u_int8_t reg_status; + u_int8_t current_flap; + enum SFDEVICE_STATE deviceState; + enum SFDEVICE_POWER powerState; }; #define SFDEVICE_MAXDEV 128 +#define SFDEVICE_MAX_X 20 +#define SFDEVICE_MAX_Y 4 + // next free slot to register device int nextFreeSlot = -1; +int deviceMap[SFDEVICE_MAX_X][SFDEVICE_MAX_Y]; + struct SFDEVICE devices[SFDEVICE_MAXDEV]; - +const char* symbols[] = {" ", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "Ä", "Ö", "Ü", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ".", "-", "?", "!"}; void devicemgr_init() { // reserve memory buffer + for (int y = 0; y= 0){ + setSingle(devices[this_id].address,*(text+i)); + } + } +} + +int devicemgr_register(int rs485_descriptor, u_int16_t address, int x,int y) { nextFreeSlot++; + devices[nextFreeSlot].pos_x = x; + devices[nextFreeSlot].pos_y = y; devices[nextFreeSlot].address = address; devices[nextFreeSlot].rs485_descriptor = rs485_descriptor; devices[nextFreeSlot].reg_voltage = 0; @@ -121,6 +170,12 @@ int devicemgr_register(int rs485_descriptor, u_int16_t address) { devices[nextFreeSlot].powerState = DISABLED; // try to reach device devicemgr_readStatus(nextFreeSlot); + if (deviceMap[x][y] >= 0){ // rest old ones + int old_id = deviceMap[x][y]; + devices[old_id].pos_x = -1; + devices[old_id].pos_y = -1; + } + deviceMap[x][y] = nextFreeSlot; return nextFreeSlot; } diff --git a/Server/src/devicemgr.h b/software/pc_client/src/devicemgr.h similarity index 85% rename from Server/src/devicemgr.h rename to software/pc_client/src/devicemgr.h index 87c617f..28d5b81 100644 --- a/Server/src/devicemgr.h +++ b/software/pc_client/src/devicemgr.h @@ -15,4 +15,5 @@ int devicemgr_readStatus(int device_id) ; json_object * devicemgr_printDetails(int device_id); json_object * devicemgr_printDetailsAll(); -int devicemgr_register(int rs485_descriptor, u_int16_t address); +int devicemgr_register(int rs485_descriptor, u_int16_t address, int x,int y); +void devicemgr_init(); \ No newline at end of file diff --git a/Server/src/main.c b/software/pc_client/src/main.c similarity index 97% rename from Server/src/main.c rename to software/pc_client/src/main.c index 06268c7..c9a66bb 100644 --- a/Server/src/main.c +++ b/software/pc_client/src/main.c @@ -67,10 +67,11 @@ int main(int argc, char *argv[]) { int fd = rs485_init(port, B19200); // setup rs485 // test - devicemgr_register(fd,0); - devicemgr_register(fd,1); + devicemgr_init(); + devicemgr_register(fd,0,0,0); + devicemgr_register(fd,1,1,0); devicemgr_printDetailsAll(); - exit(1); + //exit(1); if (strcmp(command, "ping") == 0) { sfbus_ping(fd, addr_int); diff --git a/Server/src/rs485.c b/software/pc_client/src/rs485.c similarity index 100% rename from Server/src/rs485.c rename to software/pc_client/src/rs485.c diff --git a/Server/src/rs485.h b/software/pc_client/src/rs485.h similarity index 100% rename from Server/src/rs485.h rename to software/pc_client/src/rs485.h diff --git a/Server/src/sfbus.c b/software/pc_client/src/sfbus.c similarity index 100% rename from Server/src/sfbus.c rename to software/pc_client/src/sfbus.c diff --git a/Server/src/sfbus.h b/software/pc_client/src/sfbus.h similarity index 100% rename from Server/src/sfbus.h rename to software/pc_client/src/sfbus.h