diff --git a/firmware/motion-head/src/main.cpp b/firmware/motion-head/src/main.cpp index 67b3a8ee350e35c61008e4d4e7cfdfe2f8808631..08e9864a743bcf060b589b19483c12b9a3abcfe7 100644 --- a/firmware/motion-head/src/main.cpp +++ b/firmware/motion-head/src/main.cpp @@ -202,6 +202,10 @@ void setup() { DEBUG2PIN_SETUP; DEBUG3PIN_SETUP; DEBUG4PIN_SETUP; + // l i g h t s + ERRLIGHT_ON; + CLKLIGHT_ON; + /* // osap osapSetup(); // ports @@ -226,19 +230,47 @@ void setup() { // smoothie (and frequency of loop below) #warning pls reconsider maximal rates / etc given new loop freq... and how / where to parameterize smoothieRoll->init(20000); + */ + // bare serial + Serial.begin(9600); + // barebus + ucBusHead_setup(); // 25kHz base (40us period) or // 20kHz base (50us period) - d51ClockBoss->start_ticker_a(50); - // l i g h t s - ERRLIGHT_ON; - CLKLIGHT_ON; + d51ClockBoss->start_ticker_a(100); } +unsigned long lastTx = 0; +uint8_t testTx[33] = { + 1, 2, 3, 4, 0, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33 }; + +uint8_t tstRx[256]; + +#define TEST_TX + void loop() { // write ~ every second, transmit on chb to drop 1 // check indices on the way down / up ... was shifting, are not anymore - osapLoop(); - conveyor->on_idle(nullptr); + //osapLoop(); + //conveyor->on_idle(nullptr); + + if(ucBusHead_ctr(1)){ + uint16_t len = ucBusHead_read(1, tstRx); + logPacket(tstRx, len); + } + #ifdef TEST_TX + if(millis() > lastTx + 100){ + lastTx = millis(); + if(ucBusHead_ctsB(1)){ + //logPacket(testTx, 15); + ucBusHead_transmitB(testTx, 22, 1); + DEBUG1PIN_TOGGLE; + } + } + #endif } // end loop // runs on period defined by timer_a setup: @@ -255,12 +287,13 @@ void TC0_Handler(void){ timeTick ++; timeBlink ++; if(timeBlink > blinkTime){ - DEBUG1PIN_TOGGLE; + //DEBUG1PIN_TOGGLE; timeBlink = 0; } // do bus action first: want downstream clocks to be deterministic-ish ucBusHead_timerISR(); // do step tick + /* smoothieRoll->step_tick(); // every n ticks, ship position? // each of these ticks drops 10 data bytes, so if we have 17 byte packet, can do every 2nd packet @@ -285,4 +318,5 @@ void TC0_Handler(void){ //ucBusHead_transmitA(motion_packet, 17); //DEBUG3PIN_OFF; } + */ } diff --git a/firmware/motion-head/src/osape-d51 b/firmware/motion-head/src/osape-d51 index e926d28ae33499d1bbb96df5933fba47e7d5eec7..7d0be7a5c309aab2a3300116c7e9fd2c425fc6cb 160000 --- a/firmware/motion-head/src/osape-d51 +++ b/firmware/motion-head/src/osape-d51 @@ -1 +1 @@ -Subproject commit e926d28ae33499d1bbb96df5933fba47e7d5eec7 +Subproject commit 7d0be7a5c309aab2a3300116c7e9fd2c425fc6cb diff --git a/firmware/motion-head/src/syserror.cpp b/firmware/motion-head/src/syserror.cpp index c560e1340f6ea684d19198509e0246f200bb3d3a..67d696423fd8fe65da6fb351fc29afa9136b24ac 100644 --- a/firmware/motion-head/src/syserror.cpp +++ b/firmware/motion-head/src/syserror.cpp @@ -68,10 +68,11 @@ void sysError(String msg){ errBuf[6] = (len >> 24) & 255; msg.getBytes(&(errBuf[7]), len + 1); size_t ecl = cobsEncode(errBuf, len + 7, errEncoded); + errEncoded[ecl] = 0; // direct escape //if(Serial.availableForWrite() > (int64_t)ecl){ - Serial.write(errEncoded, ecl); - Serial.flush(); + Serial.write(errEncoded, ecl + 1); + //Serial.flush(); //} else { // ERRLIGHT_ON; //}