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
Tags
No related merge requests found
......@@ -27,3 +27,6 @@
#define DEBUG1PIN_OFF DEBUG1PIN_PORT.OUTCLR.reg = DEBUG1PIN_BM
#define DEBUG1PIN_TOGGLE DEBUG1PIN_PORT.OUTTGL.reg = DEBUG1PIN_BM
#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 "indicators.h"
#include "config.h"
//#include "../../drivers/indicators.h"
#include "osape-d21/osape/osap/ts.h"
#include "osape-d21/osape/utils/cobs.h"
uint8_t errBuf[1028];
uint8_t errEncoded[1028];
/*
boolean writeString(unsigned char* dest, uint16_t* dptr, String msg){
uint16_t len = msg.length();
dest[(*dptr) ++] = TS_STRING_KEY;
writeLenBytes(dest, dptr, len);
msg.getBytes(dest, len + 1);
return true;
}
volatile unsigned long errLightLastOn = 0;
volatile unsigned long errLightOnTime = 0;
volatile boolean errLightBlink = true;
volatile boolean errLightOn = false;
boolean writeLenBytes(unsigned char* dest, uint16_t* dptr, uint16_t len){
dest[(*dptr) ++] = len;
dest[(*dptr) ++] = (len >> 8) & 255;
return true;
void sysErrLightFlash(uint8_t level){
ERRLIGHT_ON;
errLightOn = 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];
//uint8_t escapeHeader[10] = { PK_BUSF_KEY, 0, 0, 0, 0, PK_PTR, PK_PORTF_KEY, 0, 0, PK_DEST };
#ifdef UCBUS_IS_DROP
// 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);
*/
// noop
}
#else
// config-your-own-ll-escape-hatch
void sysError(String msg){
// escape this message w/ whatever low level device you have...
// could be i.e. OLED write, here is serial print
// whatever you want,
//ERRLIGHT_ON;
uint32_t len = msg.length();
errBuf[0] = 0; // serport looks for acks in each msg, this is not one
errBuf[1] = PK_PTR;
......@@ -68,10 +63,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;
//}
......@@ -90,3 +86,4 @@ void logPacket(uint8_t* pck, uint16_t len){
}
sysError(errmsg);
}
......@@ -7,4 +7,9 @@ void sysError(String msg);
void logPacket(uint8_t* pck, 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment