mirror of
https://github.com/CamHenlin/MessagesForMacintosh.git
synced 2024-12-13 06:29:16 +00:00
bug fix: do not try to repeatedly send blank messages on enter press, attempt at speeding up debug output, add additional logging to determine which nuklear command is triggering the address error, fix some of the constructor instantiation in the js side of the app
This commit is contained in:
parent
ef29cf88e1
commit
53e2f4dba0
@ -626,6 +626,7 @@ class iMessageGraphClientClass {
|
||||
console.log(`return success`)
|
||||
|
||||
canStart = true
|
||||
lastMessageFromSerialPortTime = new Date()
|
||||
|
||||
return `success`
|
||||
}
|
||||
@ -638,6 +639,8 @@ class iMessageClient {
|
||||
|
||||
constructor () {
|
||||
|
||||
canStart = false
|
||||
|
||||
// kick off an update interval
|
||||
const updateInterval = setInterval(async () => {
|
||||
|
||||
@ -652,9 +655,9 @@ class iMessageClient {
|
||||
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)
|
||||
|
||||
|
@ -9,8 +9,11 @@ Serial implementation:
|
||||
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
|
||||
*/
|
||||
OSErr writeSerialPortDebug(short refNum, const char* str)
|
||||
{
|
||||
|
||||
short serialPort;
|
||||
|
||||
OSErr setupDebugSerialPort(short refNum) {
|
||||
|
||||
#ifdef PROFILING
|
||||
|
||||
// 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;
|
||||
|
||||
default:
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
OSErr err;
|
||||
short serialPort = 0;
|
||||
serialPort = 0;
|
||||
err = OpenDriver(nameStr, &serialPort);
|
||||
if (err < 0) return err;
|
||||
|
||||
if (err < 0) return err;
|
||||
|
||||
CntrlParam cb2;
|
||||
cb2.ioCRefNum = serialPort;
|
||||
cb2.csCode = 8;
|
||||
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;
|
||||
pb2.ioRefNum = serialPort;
|
||||
|
||||
@ -56,7 +75,7 @@ OSErr writeSerialPortDebug(short refNum, const char* str)
|
||||
pb2.ioBuffer = (Ptr) str2;
|
||||
pb2.ioReqCount = strlen(str2);
|
||||
|
||||
err = PBWrite((ParmBlkPtr)& pb2, 0);
|
||||
OSErr err = PBWrite((ParmBlkPtr)& pb2, 0);
|
||||
if (err < 0) return err;
|
||||
|
||||
// hangs on Mac512K (write hasn't finished due to slow Speed when we wants to close driver
|
||||
|
@ -3,4 +3,5 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
OSErr setupDebugSerialPort(short refNum);
|
||||
OSErr writeSerialPortDebug(short refNum, const char* str);
|
@ -271,13 +271,15 @@ void readSerialPort(char* output) {
|
||||
serGetBufStatus = SerGetBuf(incomingSerialPortReference.ioRefNum, &byteCount);
|
||||
|
||||
if (serGetBufStatus != 0 && PRINT_ERRORS) {
|
||||
|
||||
|
||||
printf("potential problem with serGetBufStatus:\n");
|
||||
char debugMessage[100];
|
||||
sprintf(debugMessage, "serGetBufStatus: %d\n", serGetBufStatus);
|
||||
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 (DEBUGGING) {
|
||||
@ -310,11 +312,11 @@ void readSerialPort(char* output) {
|
||||
}
|
||||
|
||||
memcpy(tempOutput, GlobalSerialInputBuffer, byteCount);
|
||||
|
||||
|
||||
totalByteCount += byteCount;
|
||||
|
||||
if (strstr(tempOutput, ";;@@&&") != NULL) {
|
||||
|
||||
|
||||
if (DEBUGGING) {
|
||||
|
||||
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
|
||||
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
|
||||
memset(&GlobalSerialInputBuffer[0], 0, MAX_RECEIVE_SIZE);
|
||||
|
||||
|
BIN
dist/MessagesForMacintosh.dsk
vendored
BIN
dist/MessagesForMacintosh.dsk
vendored
Binary file not shown.
BIN
dist/MessagesForMacintosh.zip
vendored
BIN
dist/MessagesForMacintosh.zip
vendored
Binary file not shown.
@ -148,6 +148,8 @@ int main()
|
||||
{
|
||||
Initialize(); /* initialize the program */
|
||||
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
|
||||
// app to load up
|
||||
|
@ -294,10 +294,28 @@ void getChatCounts() {
|
||||
return;
|
||||
}
|
||||
|
||||
strcpy(previousChatCountFunctionResponse, chatCountFunctionResponse);
|
||||
|
||||
//#ifdef MESSAGES_FOR_MACINTOSH_DEBUGGING
|
||||
writeSerialPortDebug(boutRefNum, "update current chat count");
|
||||
writeSerialPortDebug(boutRefNum, chatCountFunctionResponse);
|
||||
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
|
||||
|
||||
SysBeep(1);
|
||||
@ -425,7 +443,6 @@ void getChatCounts() {
|
||||
}
|
||||
}
|
||||
|
||||
strcpy(previousChatCountFunctionResponse, chatCountFunctionResponse);
|
||||
forceRedraw = 3;
|
||||
|
||||
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);
|
||||
|
||||
// this is the enter key, obviously
|
||||
if (edit_return_value == 17) {
|
||||
if (edit_return_value == 17 && box_input_len > 0) {
|
||||
|
||||
sendMessage();
|
||||
}
|
||||
|
@ -505,10 +505,10 @@ void updateBounds(int top, int bottom, int left, int right) {
|
||||
break;
|
||||
case NK_COMMAND_SCISSOR: {
|
||||
|
||||
#ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
|
||||
// ADDRESS ERROR DEBUGGING #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
|
||||
|
||||
writeSerialPortDebug(boutRefNum, "NK_COMMAND_SCISSOR");
|
||||
#endif
|
||||
// ADDRESS ERROR DEBUGGING #endif
|
||||
|
||||
const struct nk_command_scissor *s = (const struct nk_command_scissor*)cmd;
|
||||
|
||||
@ -545,10 +545,10 @@ void updateBounds(int top, int bottom, int left, int right) {
|
||||
break;
|
||||
case NK_COMMAND_RECT: {
|
||||
|
||||
#ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
|
||||
// ADDRESS ERROR DEBUGGING #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
|
||||
|
||||
writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT");
|
||||
#endif
|
||||
// ADDRESS ERROR DEBUGGING #endif
|
||||
|
||||
// http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/QuickDraw/QuickDraw-102.html#MARKER-9-372
|
||||
// http://mirror.informatimago.com/next/developer.apple.com/documentation/mac/QuickDraw/QuickDraw-103.html#HEADING103-0
|
||||
@ -585,10 +585,10 @@ void updateBounds(int top, int bottom, int left, int right) {
|
||||
break;
|
||||
case NK_COMMAND_RECT_FILLED: {
|
||||
|
||||
#ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
|
||||
// ADDRESS ERROR DEBUGGING #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
|
||||
|
||||
writeSerialPortDebug(boutRefNum, "NK_COMMAND_RECT_FILLED");
|
||||
#endif
|
||||
// ADDRESS ERROR DEBUGGING #endif
|
||||
|
||||
const struct nk_command_rect_filled *r = (const struct nk_command_rect_filled *)cmd;
|
||||
|
||||
@ -659,13 +659,13 @@ void updateBounds(int top, int bottom, int left, int right) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
|
||||
// ADDRESS ERROR DEBUGGING #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
|
||||
|
||||
char log[255];
|
||||
|
||||
sprintf(log, "NK_COMMAND_TEXT string: \"%s\", height: %d, length: %d, x: %d, y: %d, allowCache: %d", t->string, t->height, t->length, t->x, t->y, t->allowCache);
|
||||
writeSerialPortDebug(boutRefNum, log);
|
||||
#endif
|
||||
// ADDRESS ERROR DEBUGGING #endif
|
||||
|
||||
Rect quickDrawRectangle;
|
||||
quickDrawRectangle.top = t->y;
|
||||
@ -720,10 +720,10 @@ void updateBounds(int top, int bottom, int left, int right) {
|
||||
break;
|
||||
case NK_COMMAND_CIRCLE: {
|
||||
|
||||
#ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
|
||||
// ADDRESS ERROR DEBUGGING #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
|
||||
|
||||
writeSerialPortDebug(boutRefNum, "NK_COMMAND_CIRCLE");
|
||||
#endif
|
||||
// ADDRESS ERROR DEBUGGING #endif
|
||||
|
||||
const struct nk_command_circle *c = (const struct nk_command_circle *)cmd;
|
||||
|
||||
@ -755,10 +755,10 @@ void updateBounds(int top, int bottom, int left, int right) {
|
||||
break;
|
||||
case NK_COMMAND_CIRCLE_FILLED: {
|
||||
|
||||
#ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
|
||||
// ADDRESS ERROR DEBUGGING #ifdef NK_QUICKDRAW_GRAPHICS_DEBUGGING
|
||||
|
||||
writeSerialPortDebug(boutRefNum, "NK_COMMAND_CIRCLE_FILLED");
|
||||
#endif
|
||||
// ADDRESS ERROR DEBUGGING #endif
|
||||
|
||||
const struct nk_command_circle_filled *c = (const struct nk_command_circle_filled *)cmd;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user