diff --git a/firmware/stepper-drop/src/main.cpp b/firmware/stepper-drop/src/main.cpp index f25f17a3e619e4bde1f8468ca1775019c4dac0d3..cd3f8f84b662e3f1069bc0648d186741b2d305a5 100644 --- a/firmware/stepper-drop/src/main.cpp +++ b/firmware/stepper-drop/src/main.cpp @@ -151,6 +151,7 @@ void setup() { ERRLIGHT_SETUP; CLKLIGHT_SETUP; DEBUG1PIN_SETUP; + /* // limit switch //limitSetup(); // osap @@ -175,6 +176,10 @@ void setup() { osapAddVertex(homeStateEp); // 8 // stepper init stepper_hw->init(false, c_scale); + */ + // bare serial + Serial.begin(9600); + ucBusDrop_setup(true, 0); } // have available, @@ -185,9 +190,20 @@ void setup() { unsigned long lastTx = 0; uint8_t tstTx[14] = {1, 2, 3, 4, 5, 0, 7, 8, 9, 10, 11, 12, 13, 14}; +uint8_t tstRx[256]; + void loop() { - osapLoop(); - stepper_hw->dacRefresh(); + if(ucBusDrop_ctrB()){ + ERRLIGHT_TOGGLE; + uint16_t len = ucBusDrop_readB(tstRx); + logPacket(tstRx, len); + if(ucBusDrop_ctsB()){ + CLKLIGHT_TOGGLE; + ucBusDrop_transmitB(tstRx, len); + } + } + //osapLoop(); + //stepper_hw->dacRefresh(); #ifdef TEST_TX if(millis() > lastTx + 500){ lastTx = millis(); diff --git a/firmware/stepper-drop/src/osape-d51 b/firmware/stepper-drop/src/osape-d51 index e926d28ae33499d1bbb96df5933fba47e7d5eec7..7d0be7a5c309aab2a3300116c7e9fd2c425fc6cb 160000 --- a/firmware/stepper-drop/src/osape-d51 +++ b/firmware/stepper-drop/src/osape-d51 @@ -1 +1 @@ -Subproject commit e926d28ae33499d1bbb96df5933fba47e7d5eec7 +Subproject commit 7d0be7a5c309aab2a3300116c7e9fd2c425fc6cb diff --git a/firmware/stepper-drop/src/syserror.cpp b/firmware/stepper-drop/src/syserror.cpp index f38d38b3536fc1de97d71b82a9cb2c2130f81085..6ec72cb987f6748f9446ad0334a5b0ef11460be9 100644 --- a/firmware/stepper-drop/src/syserror.cpp +++ b/firmware/stepper-drop/src/syserror.cpp @@ -24,37 +24,6 @@ boolean writeLenBytes(unsigned char* dest, uint16_t* dptr, uint16_t len){ } */ -#ifdef UCBUS_IS_DROP - -//uint8_t escape[512]; -//uint8_t escapeHeader[10] = { PK_BUSF_KEY, 0, 0, 0, 0, PK_PTR, PK_PORTF_KEY, 0, 0, PK_DEST }; - -// config-your-own-ll-escape-hatch -void sysError(String msg){ - //ERRLIGHT_ON; - /* - uint32_t len = msg.length(); - errBuf[0] = PK_LLERR; // the ll-errmsg-key - errBuf[1] = len & 255; - errBuf[2] = (len >> 8) & 255; - errBuf[3] = (len >> 16) & 255; - errBuf[4] = (len >> 24) & 255; - msg.getBytes(&(errBuf[5]), len + 1); - // write header, - memcpy(escape, escapeHeader, 10); - // write segsize, checksum - uint16_t wptr = 10; - ts_writeUint16(128, escape, &wptr); - ts_writeUint16(len + 5, escape, &wptr); - memcpy(&(escape[wptr]), errBuf, len + 5); - // transmit on ucbus - // potential here to hang-up and do while(!(ucBusDrop->cts())) ... I *think* that would clear on an interrupt - ucBusDrop->transmit(escape, len + wptr + 5); - */ -} - -#else - // config-your-own-ll-escape-hatch void sysError(String msg){ // whatever you want, @@ -69,17 +38,11 @@ void sysError(String msg){ errBuf[6] = (len >> 24) & 255; msg.getBytes(&(errBuf[7]), len + 1); size_t ecl = cobsEncode(errBuf, len + 7, errEncoded); - // direct escape - //if(Serial.availableForWrite() > (int64_t)ecl){ - Serial.write(errEncoded, ecl); - Serial.flush(); - //} else { - // ERRLIGHT_ON; - //} + errEncoded[ecl] = 0; // add delimiter + // escape: + Serial.write(errEncoded, ecl + 1); } -#endif - void logPacket(uint8_t* pck, uint16_t len){ String errmsg; errmsg.reserve(1024);