Compare commits

...

3 Commits

9 changed files with 73 additions and 20 deletions

View File

@ -626,6 +626,7 @@ class iMessageGraphClientClass {
console.log(`return success`) console.log(`return success`)
canStart = true canStart = true
lastMessageFromSerialPortTime = new Date()
return `success` return `success`
} }
@ -638,6 +639,8 @@ class iMessageClient {
constructor () { constructor () {
canStart = false
// kick off an update interval // kick off an update interval
const updateInterval = setInterval(async () => { const updateInterval = setInterval(async () => {
@ -652,9 +655,9 @@ class iMessageClient {
return return
} }
if (new Date() - lastMessageFromSerialPortTime > 30000) { if (new Date() - lastMessageFromSerialPortTime > 300000) {
console.log(`${intervalDate}: no serial comms for 30 seconds, unloading interval`) console.log(`${intervalDate}: no serial comms for 300 seconds, unloading interval`)
clearInterval(updateInterval) clearInterval(updateInterval)

View File

@ -9,8 +9,11 @@ Serial implementation:
https://opensource.apple.com/source/gdb/gdb-186.1/src/gdb/ser-mac.c?txt https://opensource.apple.com/source/gdb/gdb-186.1/src/gdb/ser-mac.c?txt
http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/Devices/Devices-320.html http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/Devices/Devices-320.html
*/ */
OSErr writeSerialPortDebug(short refNum, const char* str)
{ short serialPort;
OSErr setupDebugSerialPort(short refNum) {
#ifdef PROFILING #ifdef PROFILING
// we need to bail on profiling, because the profile watcher will be reading this serial port // we need to bail on profiling, because the profile watcher will be reading this serial port
@ -33,21 +36,37 @@ OSErr writeSerialPortDebug(short refNum, const char* str)
break; break;
default: default:
return -1; return -1;
} }
OSErr err; OSErr err;
short serialPort = 0; serialPort = 0;
err = OpenDriver(nameStr, &serialPort); err = OpenDriver(nameStr, &serialPort);
if (err < 0) return err; if (err < 0) return err;
CntrlParam cb2; CntrlParam cb2;
cb2.ioCRefNum = serialPort; cb2.ioCRefNum = serialPort;
cb2.csCode = 8; cb2.csCode = 8;
cb2.csParam[0] = stop10 | noParity | data8 | baud9600; cb2.csParam[0] = stop10 | noParity | data8 | baud9600;
err = PBControl ((ParmBlkPtr) & cb2, 0);
if (err < 0) return err; err = PBControl ((ParmBlkPtr) & cb2, 0);
if (err < 0) {
return err;
}
return;
}
OSErr writeSerialPortDebug(short refNum, const char* str)
{
#ifdef PROFILING
// we need to bail on profiling, because the profile watcher will be reading this serial port
return;
#endif
IOParam pb2; IOParam pb2;
pb2.ioRefNum = serialPort; pb2.ioRefNum = serialPort;
@ -56,7 +75,7 @@ OSErr writeSerialPortDebug(short refNum, const char* str)
pb2.ioBuffer = (Ptr) str2; pb2.ioBuffer = (Ptr) str2;
pb2.ioReqCount = strlen(str2); pb2.ioReqCount = strlen(str2);
err = PBWrite((ParmBlkPtr)& pb2, 0); OSErr err = PBWrite((ParmBlkPtr)& pb2, 0);
if (err < 0) return err; if (err < 0) return err;
// hangs on Mac512K (write hasn't finished due to slow Speed when we wants to close driver // hangs on Mac512K (write hasn't finished due to slow Speed when we wants to close driver

View File

@ -3,4 +3,5 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
OSErr setupDebugSerialPort(short refNum);
OSErr writeSerialPortDebug(short refNum, const char* str); OSErr writeSerialPortDebug(short refNum, const char* str);

View File

@ -271,13 +271,15 @@ void readSerialPort(char* output) {
serGetBufStatus = SerGetBuf(incomingSerialPortReference.ioRefNum, &byteCount); serGetBufStatus = SerGetBuf(incomingSerialPortReference.ioRefNum, &byteCount);
if (serGetBufStatus != 0 && PRINT_ERRORS) { if (serGetBufStatus != 0 && PRINT_ERRORS) {
printf("potential problem with serGetBufStatus:\n"); printf("potential problem with serGetBufStatus:\n");
char debugMessage[100]; char debugMessage[100];
sprintf(debugMessage, "serGetBufStatus: %d\n", serGetBufStatus); sprintf(debugMessage, "serGetBufStatus: %d\n", serGetBufStatus);
printf(debugMessage); printf(debugMessage);
} }
// basically, we're stating that if we have a stall for 2 iterations of the loop where the byteCounts are matching, then
// we assume we are no longer receiving communication. could have bugs? ie, we could be "done" reading before the data is all written
if (byteCount == lastByteCount && byteCount != 0 && lastByteCount != 0) { if (byteCount == lastByteCount && byteCount != 0 && lastByteCount != 0) {
if (DEBUGGING) { if (DEBUGGING) {
@ -310,11 +312,11 @@ void readSerialPort(char* output) {
} }
memcpy(tempOutput, GlobalSerialInputBuffer, byteCount); memcpy(tempOutput, GlobalSerialInputBuffer, byteCount);
totalByteCount += byteCount; totalByteCount += byteCount;
if (strstr(tempOutput, ";;@@&&") != NULL) { if (strstr(tempOutput, ";;@@&&") != NULL) {
if (DEBUGGING) { if (DEBUGGING) {
printf("done building temp output\n"); printf("done building temp output\n");
@ -336,6 +338,9 @@ void readSerialPort(char* output) {
// attach the gathered up output from the buffer to the output variable // attach the gathered up output from the buffer to the output variable
strncat(output, tempOutput, totalByteCount); strncat(output, tempOutput, totalByteCount);
writeSerialPortDebug(boutRefNum, "coprocessor.readSerialPort complete, output:");
writeSerialPortDebug(boutRefNum, output);
// once we are done reading the buffer entirely, we need to clear it. i'm not sure if this is the best way or not but seems to work // once we are done reading the buffer entirely, we need to clear it. i'm not sure if this is the best way or not but seems to work
memset(&GlobalSerialInputBuffer[0], 0, MAX_RECEIVE_SIZE); memset(&GlobalSerialInputBuffer[0], 0, MAX_RECEIVE_SIZE);

Binary file not shown.

Binary file not shown.

View File

@ -148,6 +148,8 @@ int main()
{ {
Initialize(); /* initialize the program */ Initialize(); /* initialize the program */
UnloadSeg((Ptr) Initialize); /* note that Initialize must not be in Main! */ UnloadSeg((Ptr) Initialize); /* note that Initialize must not be in Main! */
setupDebugSerialPort(boutRefNum);
writeSerialPortDebug(boutRefNum, "initializing messages for macintosh");
// run our nuklear app one time to render the window telling us to be patient for the coprocessor // run our nuklear app one time to render the window telling us to be patient for the coprocessor
// app to load up // app to load up

View File

@ -294,10 +294,28 @@ void getChatCounts() {
return; return;
} }
strcpy(previousChatCountFunctionResponse, chatCountFunctionResponse);
//#ifdef MESSAGES_FOR_MACINTOSH_DEBUGGING //#ifdef MESSAGES_FOR_MACINTOSH_DEBUGGING
writeSerialPortDebug(boutRefNum, "update current chat count"); writeSerialPortDebug(boutRefNum, "update current chat count");
writeSerialPortDebug(boutRefNum, chatCountFunctionResponse); writeSerialPortDebug(boutRefNum, chatCountFunctionResponse);
writeSerialPortDebug(boutRefNum, previousChatCountFunctionResponse); writeSerialPortDebug(boutRefNum, previousChatCountFunctionResponse);
// update current chat count
// 1
// wrangled byn
// wrangled by the knockers:::0,Aaron Sunderland:::0,Shirley Waggoner:::0,waggoner6171@icloud.com:::0,Rebecca Henlin:::0,Chris Sjoblom:::0,Leo Torbochkin:::0,Jayant Sai:::0,+15095713317:::0,Adam Struthers:::0
// 2
// wrangled by the knockers:::0,Aaron Sunderland:::0,Shin
// wrangled by the knockers:::0,Aaron Sunderland:::0,Shirley Waggoner:::0,waggoner6171@icloud.com:::0,Rebecca Henlin:::0,Chris Sjoblom:::0,Leo Torbochkin:::0,Jayant Sai:::0,+15095713317:::0,Adam Struthers:::0
// 3
// wrangled by the knockers:::0,Aaron Sunderland:::0,n
// wrangled by the knockers:::0,Aaron Sunderland:::0,Shirley Waggoner:::0,waggoner6171@icloud.com:::0,Rebecca Henlin:::0,Chris Sjoblom:::0,Leo Torbochkin:::0,Jayant Sai:::0,+15095713317:::0,Adam Struthers:::0
// 4
// wrangled by the knockers:::0,Aaron Sunderland:::0,Shirley Waggoner:::0,waggoner6171@icloud.com:::0,Rebecca Henlin:::0,Chris Sjoblom:::0,Leo Torbochkin:::0,Jayant Sai:::0,+15095713317:::0,Adam Struthers:::0
// wrangled by the knockers:::0,Aaron Sunderland:::0,n
//#endif //#endif
SysBeep(1); SysBeep(1);
@ -425,7 +443,6 @@ void getChatCounts() {
} }
} }
strcpy(previousChatCountFunctionResponse, chatCountFunctionResponse);
forceRedraw = 3; forceRedraw = 3;
return; return;
@ -669,7 +686,7 @@ static void nuklearApp(struct nk_context *ctx) {
short edit_return_value = nk_edit_string(ctx, NK_EDIT_FIELD|NK_EDIT_SIG_ENTER, box_input_buffer, &box_input_len, 2048, nk_filter_default); short edit_return_value = nk_edit_string(ctx, NK_EDIT_FIELD|NK_EDIT_SIG_ENTER, box_input_buffer, &box_input_len, 2048, nk_filter_default);
// this is the enter key, obviously // this is the enter key, obviously
if (edit_return_value == 17) { if (edit_return_value == 17 && box_input_len > 0) {
sendMessage(); sendMessage();
} }

View File

@ -458,9 +458,9 @@ int mostRight = 1;
void updateBounds(int top, int bottom, int left, int right) { void updateBounds(int top, int bottom, int left, int right) {
// #ifdef DEBUG_FUNCTION_CALLS #ifdef DEBUG_FUNCTION_CALLS
writeSerialPortDebug(boutRefNum, "DEBUG_FUNCTION_CALLS: updateBounds"); writeSerialPortDebug(boutRefNum, "DEBUG_FUNCTION_CALLS: updateBounds");
// #endif #endif
if (left < mostLeft) { if (left < mostLeft) {
@ -481,7 +481,6 @@ void updateBounds(int top, int bottom, int left, int right) {
mostBottom = bottom; mostBottom = bottom;
} }
writeSerialPortDebug(boutRefNum, "END OF DEBUG_FUNCTION_CALLS: updateBounds");
} }
#ifdef COMMAND_CACHING #ifdef COMMAND_CACHING
@ -1137,12 +1136,16 @@ NK_API void nk_quickdraw_render(WindowPtr window, struct nk_context *ctx) {
#endif #endif
#ifdef COMMAND_CACHING #ifdef COMMAND_CACHING
writeSerialPortDebug(boutRefNum, "INCREMENT LAST CMD");
if (currentCalls <= lastCalls && lastCmd && lastCmd->next && lastCmd->next < ctx->memory.allocated) { if (currentCalls <= lastCalls && lastCmd && lastCmd->next && lastCmd->next < ctx->memory.allocated) {
writeSerialPortDebug(boutRefNum, "INCREMENT LAST CMD: IN CONDITIONAL");
lastCmd = nk_ptr_add_const(struct nk_command, last, lastCmd->next); lastCmd = nk_ptr_add_const(struct nk_command, last, lastCmd->next);
} }
currentCalls++; currentCalls++;
writeSerialPortDebug(boutRefNum, "DONE INCREMENT LAST CMD");
#endif #endif
} }
@ -1172,6 +1175,8 @@ NK_API void nk_quickdraw_render(WindowPtr window, struct nk_context *ctx) {
PROFILE_START("copy bits"); PROFILE_START("copy bits");
#endif #endif
writeSerialPortDebug(boutRefNum, "COPYBITS PROCESS");
SetPort(window); SetPort(window);
Rect quickDrawRectangle; Rect quickDrawRectangle;
@ -1181,6 +1186,7 @@ NK_API void nk_quickdraw_render(WindowPtr window, struct nk_context *ctx) {
quickDrawRectangle.right = mostRight; quickDrawRectangle.right = mostRight;
CopyBits(&gMainOffScreen.bits->portBits, &window->portBits, &quickDrawRectangle, &quickDrawRectangle, srcCopy, 0L); CopyBits(&gMainOffScreen.bits->portBits, &window->portBits, &quickDrawRectangle, &quickDrawRectangle, srcCopy, 0L);
writeSerialPortDebug(boutRefNum, "DONE COPYBITS PROCESS");
mostLeft = WINDOW_WIDTH; mostLeft = WINDOW_WIDTH;
mostBottom = 1; mostBottom = 1;