Skip to content
Snippets Groups Projects
Commit 9f47d99a authored by Jake Read's avatar Jake Read
Browse files

rollup w/ osape update

parent 7155a376
Branches
No related tags found
No related merge requests found
...@@ -27,3 +27,6 @@ ...@@ -27,3 +27,6 @@
#define DEBUG1PIN_OFF DEBUG1PIN_PORT.OUTCLR.reg = DEBUG1PIN_BM #define DEBUG1PIN_OFF DEBUG1PIN_PORT.OUTCLR.reg = DEBUG1PIN_BM
#define DEBUG1PIN_TOGGLE DEBUG1PIN_PORT.OUTTGL.reg = DEBUG1PIN_BM #define DEBUG1PIN_TOGGLE DEBUG1PIN_PORT.OUTTGL.reg = DEBUG1PIN_BM
#define DEBUG1PIN_SETUP DEBUG1PIN_PORT.DIRSET.reg = DEBUG1PIN_BM; DEBUG1PIN_OFF #define DEBUG1PIN_SETUP DEBUG1PIN_PORT.DIRSET.reg = DEBUG1PIN_BM; DEBUG1PIN_OFF
#define ERRLIGHT_ON
#define ERRLIGHT_OFF
Subproject commit b47769ec7b9994fb363d881929520afbf4589200 Subproject commit d7df297e7039d697def2a1252e34eebfa3981e1d
#include "syserror.h" #include "syserror.h"
#include "indicators.h"
#include "config.h" #include "config.h"
//#include "../../drivers/indicators.h"
#include "osape-d21/osape/osap/ts.h" #include "osape-d21/osape/osap/ts.h"
#include "osape-d21/osape/utils/cobs.h" #include "osape-d21/osape/utils/cobs.h"
uint8_t errBuf[1028]; uint8_t errBuf[1028];
uint8_t errEncoded[1028]; uint8_t errEncoded[1028];
/* volatile unsigned long errLightLastOn = 0;
boolean writeString(unsigned char* dest, uint16_t* dptr, String msg){ volatile unsigned long errLightOnTime = 0;
uint16_t len = msg.length(); volatile boolean errLightBlink = true;
dest[(*dptr) ++] = TS_STRING_KEY; volatile boolean errLightOn = false;
writeLenBytes(dest, dptr, len);
msg.getBytes(dest, len + 1);
return true;
}
boolean writeLenBytes(unsigned char* dest, uint16_t* dptr, uint16_t len){ void sysErrLightFlash(uint8_t level){
dest[(*dptr) ++] = len; ERRLIGHT_ON;
dest[(*dptr) ++] = (len >> 8) & 255; errLightOn = true;
return true; errLightLastOn = millis();
switch(level){
case 0:
errLightBlink = false;
break;
case 1:
errLightOnTime = 5000;
break;
case 2:
errLightOnTime = 1000;
break;
case 3:
errLightOnTime = 250;
break;
}
} }
*/
#ifdef SPIPHY_IS_DROP void sysErrLightCheck(void){
if(errLightOn && errLightBlink){
if(errLightLastOn + errLightOnTime < millis()){
ERRLIGHT_OFF;
errLightOn = false;
}
}
}
//uint8_t escape[512]; #ifdef UCBUS_IS_DROP
//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){ void sysError(String msg){
//ERRLIGHT_ON; // noop
/*
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 #else
// config-your-own-ll-escape-hatch // config-your-own-ll-escape-hatch
void sysError(String msg){ void sysError(String msg){
// escape this message w/ whatever low level device you have... // whatever you want,
// could be i.e. OLED write, here is serial print //ERRLIGHT_ON;
uint32_t len = msg.length(); uint32_t len = msg.length();
errBuf[0] = 0; // serport looks for acks in each msg, this is not one errBuf[0] = 0; // serport looks for acks in each msg, this is not one
errBuf[1] = PK_PTR; errBuf[1] = PK_PTR;
...@@ -68,10 +63,11 @@ void sysError(String msg){ ...@@ -68,10 +63,11 @@ void sysError(String msg){
errBuf[6] = (len >> 24) & 255; errBuf[6] = (len >> 24) & 255;
msg.getBytes(&(errBuf[7]), len + 1); msg.getBytes(&(errBuf[7]), len + 1);
size_t ecl = cobsEncode(errBuf, len + 7, errEncoded); size_t ecl = cobsEncode(errBuf, len + 7, errEncoded);
errEncoded[ecl] = 0;
// direct escape // direct escape
//if(Serial.availableForWrite() > (int64_t)ecl){ //if(Serial.availableForWrite() > (int64_t)ecl){
Serial.write(errEncoded, ecl); Serial.write(errEncoded, ecl + 1);
Serial.flush(); //Serial.flush();
//} else { //} else {
// ERRLIGHT_ON; // ERRLIGHT_ON;
//} //}
...@@ -90,3 +86,4 @@ void logPacket(uint8_t* pck, uint16_t len){ ...@@ -90,3 +86,4 @@ void logPacket(uint8_t* pck, uint16_t len){
} }
sysError(errmsg); sysError(errmsg);
} }
...@@ -7,4 +7,9 @@ void sysError(String msg); ...@@ -7,4 +7,9 @@ void sysError(String msg);
void logPacket(uint8_t* pck, uint16_t len); void logPacket(uint8_t* pck, uint16_t len);
//void sysError(uint8_t* bytes, uint16_t len); //void sysError(uint8_t* bytes, uint16_t len);
void sysErrLightFlash(uint8_t level);
void sysErrLightCheck(void);
#define ERROR(level, msg) sysErrLightFlash(level); sysError(msg)
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment