Skip to content

Commit

Permalink
Daniel/test framework glove bg (#9)
Browse files Browse the repository at this point in the history
* Changes for new glove background
* Added resource
* Some fixes for glove display and added icon
* Vortex Emulator
* Adjusted the color
  • Loading branch information
Unreal-Dan authored Jan 18, 2023
1 parent b894903 commit 33f3102
Show file tree
Hide file tree
Showing 11 changed files with 299 additions and 59 deletions.
33 changes: 29 additions & 4 deletions VortexTestingFramework/EngineDependencies/Arduino.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "TestFramework.h"
#endif

#include "VortexConfig.h"

#include <chrono>
#include <random>
#include <time.h>
Expand Down Expand Up @@ -69,7 +71,7 @@ void init_arduino()
hPipe = CreateNamedPipe(
"\\\\.\\pipe\\vortextestframework",
PIPE_ACCESS_DUPLEX,
PIPE_TYPE_BYTE|PIPE_READMODE_BYTE|PIPE_NOWAIT,
PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT,
1,
4096,
4096,
Expand All @@ -80,9 +82,26 @@ void init_arduino()
error += std::to_string(GetLastError());
MessageBox(NULL, error.c_str(), "", 0);
}
// try to find editor window
HWND hwnd = FindWindow("VWINDOW", NULL);
if (hwnd != NULL) {
// send it a message to tell it the test framework is here
PostMessage(hwnd, WM_USER + 1, 0 ,0);
}
#endif
}

void cleanup_arduino()
{
HWND hwnd = FindWindow("VWINDOW", NULL);
if (hwnd != NULL) {
PostMessage(hwnd, WM_USER + 2, 0, 0);
}
if (hPipe) {
DisconnectNamedPipe(hPipe);
}
}

void delay(size_t amt)
{
#ifdef LINUX_FRAMEWORK
Expand Down Expand Up @@ -252,7 +271,6 @@ uint32_t SerialClass::write(const uint8_t *buf, size_t len)
}
total += written;
} while (total < len);
FlushFileBuffers(hPipe);
return total;
}

Expand All @@ -262,8 +280,11 @@ SerialClass::operator bool()
return true;
}
// create a global pipe
if (!ConnectNamedPipe(hPipe, NULL) && GetLastError() != ERROR_PIPE_CONNECTED) {
return false;
if (!ConnectNamedPipe(hPipe, NULL)) {
int err = GetLastError();
if (err != ERROR_PIPE_CONNECTED && err != ERROR_PIPE_LISTENING) {
return false;
}
}
connected = true;
return true;
Expand All @@ -284,6 +305,10 @@ size_t SerialClass::readBytes(char *buf, size_t amt)
DWORD numRead = 0;
do {
if (!ReadFile(hPipe, buf + total, amt - total, &numRead, NULL)) {
int err = GetLastError();
if (err == ERROR_PIPE_NOT_CONNECTED) {
printf("Fail\n");
}
break;
}
total += numRead;
Expand Down
1 change: 1 addition & 0 deletions VortexTestingFramework/EngineDependencies/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

// init this drop-in framework
void init_arduino();
void cleanup_arduino();

void delay(size_t amt);
void delayMicroseconds(size_t us);
Expand Down
Loading

0 comments on commit 33f3102

Please sign in to comment.