Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
cd6f665
Adding support for auxCxnController and auxInstructionQ
nitin710 Aug 15, 2024
723d280
switched to JSON packet structure from EmotiBit packet structure
nitin710 Aug 28, 2024
8f1e3d5
removed parsing emotibit packet structure from wifi host
nitin710 Aug 28, 2024
2a34f5c
removed Q parsing function def in ofApp. Needs to be re-written for JSON
nitin710 Aug 28, 2024
e4bcfd2
process aux instruction based on version
nitin710 Sep 4, 2024
d3b5e53
Merge branch 'master' into feat-OscilloscopeControlAutomation
nitin710 Sep 4, 2024
eb5cf52
version update
nitin710 Sep 4, 2024
7e27213
updating variable names to match convention
nitin710 Sep 5, 2024
9e4427f
updated come var names. Changed operation on q processing by using in…
nitin710 Sep 5, 2024
7ce645d
changing JSON keys
nitin710 Sep 8, 2024
9dde703
adding helper scripts to test EmotiBit Oscilloscope control from console
nitin710 Sep 8, 2024
f353460
removed old unused code
nitin710 Sep 8, 2024
40a9640
minor mods.
nitin710 Sep 8, 2024
5f68aff
removing a change to sendControl to take it back to original behavior
nitin710 Sep 11, 2024
8b413b6
change cont.
nitin710 Sep 11, 2024
9485452
updates shell scripts
nitin710 Sep 11, 2024
a900852
updating shell script with some helpful echo prints
nitin710 Sep 11, 2024
efcf61c
pulled latest master
nitin710 Jul 10, 2025
a8e4175
Merge branch 'dev' into feat-OscilloscopeControlAutomation
nitin710 Jul 10, 2025
869a2dd
Added a fix to AuxInstrQ to remove OF dependency
nitin710 Jul 10, 2025
4e80ea0
compiling on mac
nitin710 Jul 10, 2025
38bb7b0
fix compile on linux. remove pow (math.h) from auxCxnController
nitin710 Jul 10, 2025
6a86819
Adding provision to send user notes using the Aux Cxn
nitin710 Jul 10, 2025
0b11469
updated test details for oscillosocpe automated control test
nitin710 Jul 28, 2025
484f7a7
pulled latest dev
nitin710 Jul 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions EmotiBitOscilloscope/EmotiBitOscilloscope.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@
<ClCompile Include="..\src\EmotiBitOfUtils.cpp" />
<ClCompile Include="..\src\Signal\Periodizer.cpp" />
<ClCompile Include="..\src\SoftwareVersionChecker.cpp" />
<ClCompile Include="src\AuxInstrQ.cpp" />
<ClCompile Include="src\AuxCxnController.cpp" />
<ClCompile Include="src\EmotiBitLsl.cpp" />
<ClCompile Include="src\EmotiBitWiFiHost.cpp" />
<ClCompile Include="src\main.cpp" />
Expand Down Expand Up @@ -175,6 +177,8 @@
<ClInclude Include="..\src\SoftwareVersionChecker.h" />
<ClInclude Include="src\EmotiBitLsl.h" />
<ClInclude Include="src\EmotiBitWiFiHost.h" />
<ClInclude Include="src\AuxInstrQ.h" />
<ClInclude Include="src\AuxCxnController.h" />
<ClInclude Include="src\ofApp.h" />
<ClInclude Include="..\..\..\addons\ofxBiquadFilter\src\ofxBiquadFilter.h" />
<ClInclude Include="..\..\..\addons\ofxBiquadFilter\src\ofxBiquadFilterInstance.h" />
Expand Down
16 changes: 15 additions & 1 deletion EmotiBitOscilloscope/EmotiBitOscilloscope.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,18 @@
<ClCompile Include="..\src\EmotiBitOfUtils.cpp">
<Filter>addons\ofxEmotiBit\src</Filter>
</ClCompile>
<ClCompile Include="..\src\SoftwareVersionChecker.cpp" />
<ClCompile Include="..\src\SoftwareVersionChecker.cpp">
<Filter>addons\ofxEmotiBit\src</Filter>
</ClCompile>
<ClCompile Include="src\AuxInstrQ.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="src\EmotiBitWiFiHost.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="src\AuxCxnController.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="src\EmotiBitLsl.cpp">
<Filter>src</Filter>
</ClCompile>
Expand Down Expand Up @@ -552,9 +560,15 @@
<ClInclude Include="..\src\EmotiBitOfUtils.h">
<Filter>addons\ofxEmotiBit\src</Filter>
</ClInclude>
<ClInclude Include="src\AuxInstrQ.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="src\EmotiBitWiFiHost.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="src\AuxCxnController.h">
<Filter>src</Filter>
</ClInclude>
<ClInclude Include="src\EmotiBitLsl.h">
<Filter>src</Filter>
</ClInclude>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
8E80A3642CCDAAA000C65119 /* EmotiBitLsl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8E80A35F2CCDAAA000C65119 /* EmotiBitLsl.cpp */; };
8E80A3652CCDAAA000C65119 /* EmotiBitWiFiHost.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8E80A3622CCDAAA000C65119 /* EmotiBitWiFiHost.cpp */; };
8E80A3662CCDAAA000C65119 /* EmotiBitWiFiHost.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8E80A3622CCDAAA000C65119 /* EmotiBitWiFiHost.cpp */; };
8EF01A612E20483A00BF0971 /* AuxInstrQ.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8EF01A5D2E20483900BF0971 /* AuxInstrQ.cpp */; };
8EF01A622E20483A00BF0971 /* AuxInstrQ.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8EF01A5D2E20483900BF0971 /* AuxInstrQ.cpp */; };
8EF01A632E20483A00BF0971 /* AuxCxnController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8EF01A5E2E20483A00BF0971 /* AuxCxnController.cpp */; };
8EF01A642E20483A00BF0971 /* AuxCxnController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8EF01A5E2E20483A00BF0971 /* AuxCxnController.cpp */; };
8F5205AEF8861EF234F0651A /* ofxOscSender.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 81967292BFC87A0144BD32C6 /* ofxOscSender.cpp */; };
933A2227713C720CEFF80FD9 /* tinyxml.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2B40EDA85BEB63E46785BC29 /* tinyxml.cpp */; };
941B2FC325BA241400BB7E84 /* oscOutputSettings.xml in Copy Files */ = {isa = PBXBuildFile; fileRef = 941B2FB525B8EA3200BB7E84 /* oscOutputSettings.xml */; };
Expand Down Expand Up @@ -317,6 +321,10 @@
8E80A3602CCDAAA000C65119 /* EmotiBitWiFiHost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EmotiBitWiFiHost.h; sourceTree = "<group>"; };
8E80A3612CCDAAA000C65119 /* EmotiBitLsl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EmotiBitLsl.h; sourceTree = "<group>"; };
8E80A3622CCDAAA000C65119 /* EmotiBitWiFiHost.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EmotiBitWiFiHost.cpp; sourceTree = "<group>"; };
8EF01A5D2E20483900BF0971 /* AuxInstrQ.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AuxInstrQ.cpp; sourceTree = "<group>"; };
8EF01A5E2E20483A00BF0971 /* AuxCxnController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AuxCxnController.cpp; sourceTree = "<group>"; };
8EF01A5F2E20483A00BF0971 /* AuxInstrQ.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AuxInstrQ.h; sourceTree = "<group>"; };
8EF01A602E20483A00BF0971 /* AuxCxnController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AuxCxnController.h; sourceTree = "<group>"; };
8EFF3F692DFC7A1800FB6792 /* ArduinoString.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ArduinoString.h; path = ../../EmotiBit_XPlat_Utils/src/ArduinoString.h; sourceTree = "<group>"; };
8F225C97B6ECA8B22FFB4B76 /* rc5.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; name = rc5.h; path = ../../../addons/ofxPoco/libs/openssl/include/openssl/rc5.h; sourceTree = SOURCE_ROOT; };
907C5B5E104864A2D3A25745 /* ofxToggle.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.cpp; fileEncoding = 4; name = ofxToggle.cpp; path = ../../../addons/ofxGui/src/ofxToggle.cpp; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -1546,6 +1554,10 @@
E4B69E1C0A3A1BDC003C02F2 /* src */ = {
isa = PBXGroup;
children = (
8EF01A5E2E20483A00BF0971 /* AuxCxnController.cpp */,
8EF01A602E20483A00BF0971 /* AuxCxnController.h */,
8EF01A5D2E20483900BF0971 /* AuxInstrQ.cpp */,
8EF01A5F2E20483A00BF0971 /* AuxInstrQ.h */,
8E80A35F2CCDAAA000C65119 /* EmotiBitLsl.cpp */,
8E80A3612CCDAAA000C65119 /* EmotiBitLsl.h */,
8E80A3622CCDAAA000C65119 /* EmotiBitWiFiHost.cpp */,
Expand Down Expand Up @@ -1811,10 +1823,12 @@
B990E5C72C0E7A370094B63E /* PatchboardJson.cpp in Sources */,
B990E5C82C0E7A370094B63E /* ofxColorPicker.cpp in Sources */,
B990E5C92C0E7A370094B63E /* ofxGuiGroup.cpp in Sources */,
8EF01A632E20483A00BF0971 /* AuxCxnController.cpp in Sources */,
B990E5CA2C0E7A370094B63E /* ofxInputField.cpp in Sources */,
B990E5CB2C0E7A370094B63E /* DigitalFilter.cpp in Sources */,
B990E5CC2C0E7A370094B63E /* ofxLabel.cpp in Sources */,
B990E5CD2C0E7A370094B63E /* Periodizer.cpp in Sources */,
8EF01A612E20483A00BF0971 /* AuxInstrQ.cpp in Sources */,
B990E5CE2C0E7A370094B63E /* ofxPanel.cpp in Sources */,
B990E5CF2C0E7A370094B63E /* ofxSlider.cpp in Sources */,
B990E5D02C0E7A370094B63E /* ofxSliderGroup.cpp in Sources */,
Expand Down Expand Up @@ -1878,10 +1892,12 @@
8E07BBCD2BB3B2BF00CDD443 /* PatchboardJson.cpp in Sources */,
853E0BA2F448076739446874 /* ofxColorPicker.cpp in Sources */,
B266578FC55D23BFEBC042E7 /* ofxGuiGroup.cpp in Sources */,
8EF01A642E20483A00BF0971 /* AuxCxnController.cpp in Sources */,
852E0891794923EE7583C621 /* ofxInputField.cpp in Sources */,
8E016F7E2832CE28005D7C65 /* DigitalFilter.cpp in Sources */,
483908258D00B98B4BE69F07 /* ofxLabel.cpp in Sources */,
8E016F842832CE82005D7C65 /* Periodizer.cpp in Sources */,
8EF01A622E20483A00BF0971 /* AuxInstrQ.cpp in Sources */,
F285EB3169F1566CA3D93C20 /* ofxPanel.cpp in Sources */,
837220E80EB56CD44AD27F2A /* ofxSlider.cpp in Sources */,
B56FE57CC35806596D38118C /* ofxSliderGroup.cpp in Sources */,
Expand Down
147 changes: 147 additions & 0 deletions EmotiBitOscilloscope/src/AuxCxnController.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#include "AuxCxnController.h"

std::uint16_t AuxCxnController::begin()
{
// start the UDP channel
auxCxnUdp.Create();
auxCxnUdp.SetNonBlocking(true);
auxCxnUdp.SetReceiveBufferSize(UDP_CXN_BUFFER_SIZE); // 8KB
auxCxnUdp.Bind(auxPort);

// setup TCP channel
// ToDo: setup for TCP channel

return 0;
}

void AuxCxnController::readAuxCxn(AuxChannel channel)
{
const int maxSize = 32768;
static char udpMessage[maxSize];
int msgSize = 0;
static struct Remote {
std::string ip;
int port;
}remote;
if (channel == AuxChannel::CHANNEL_UDP)
{
// Read the UDP channel
msgSize = auxCxnUdp.Receive(udpMessage, maxSize);
auxCxnUdp.GetRemoteAddr(remote.ip, remote.port);
if (msgSize)
{
// debug test code
ofLogVerbose("AuxCxnController") << "UDP message received from remote (IP:port) = (" << ofToString(remote.ip) << ":" << ofToString(remote.port);
ofLogVerbose("AuxCxnController") << "Raw message: " << udpMessage;
// get packets from message
std::vector<std::string> packets = parseMessage(udpMessage);
// push packets to local queue
vector<std::string>::iterator iter = packets.begin();
for (iter; iter < packets.end(); iter++)
{
bool status = push(*iter);
if (!status)
{
ofLogWarning("AuxCxnController") << "Lost data. Failed to push message into queue: " + *iter;
}
}
}
}
else if (channel == AuxChannel::CHANNEL_TCP)
{
//ToDo: Impletement TCP channel read
}
}


std::vector<std::string> AuxCxnController::parseMessage(std::string message)
{
std::vector<std::string> packets;
// ToDo: create a new function to parse message into packets. Currently copied from wifi host. ToDo: figure out the best place for this function, given it is shared between this controller and wifihost
size_t startChar = 0;
size_t endChar;
std::string packet;
// parse packets from received message
do
{
endChar = message.find_first_of(EmotiBitPacket::PACKET_DELIMITER_CSV, startChar);
if (endChar == string::npos)
{
ofLogWarning("AuxCxnController") << "**** MALFORMED MESSAGE **** : no packet delimiter found";
}
else
{
if (endChar == startChar)
{
ofLogWarning("AuxCxnController") << "**** EMPTY MESSAGE **** ";
}
else
{
packet = message.substr(startChar, endChar - startChar); // extract packet
}
packets.push_back(packet);
}
startChar = endChar + 1;
} while (endChar != string::npos && startChar < message.size());
return packets;
}

bool AuxCxnController::push(std::string packet)
{
if (bufferQ.size() < MAX_QUEUE_SIZE)
{
bufferQ.push(packet);
}
else
{
return false;
}
return true;
}

bool AuxCxnController::pop(std::string &packet)
{
if (!bufferQ.empty())
{
packet = bufferQ.front();
bufferQ.pop();
}
else
{
return false;
}
return true;
}

bool AuxCxnController::pushToAppQ()
{
while (!bufferQ.empty())
{
if (appQ != nullptr)
{
ofLogVerbose("AuxCxnController") << "pushing to AuxInstrQ";
appQ->push(bufferQ.front());
bufferQ.pop();
}
else
{
ofLogError("AuxCxnController") << "nullptr exception! main application instruction queue is null";
return false;
}
}
return true;
}

bool AuxCxnController::attachAppQ(AuxInstrQ *q)
{
// ToDo: consider passing this as a constructor argument
if (q != nullptr)
{
appQ = q;
return true;
}
else
{
return false;
}
}
77 changes: 77 additions & 0 deletions EmotiBitOscilloscope/src/AuxCxnController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#pragma once
/* Controller for auxillary network channel*/
#include <queue>
#include <ofxUDPManager.h>
//#include <ofxTCPClient.h> // ToDo
#include <ofLog.h>
#include <ofUtils.h>
#include "EmotiBitPacket.h"
#include "AuxInstrQ.h"
#include "EmotiBitComms.h"

class AuxCxnController {
const uint32_t UDP_CXN_BUFFER_SIZE = 8192; // 8KB
public:
enum AuxChannel {
CHANNEL_UDP = 0,
CHANNEL_TCP
};
int auxPort = EmotiBitComms::WIFI_ADVERTISING_PORT - 1; ///< Port where auxillary messages can be sent to the oscilloscope
const int MAX_QUEUE_SIZE = 1000; // random number chosen for now

ofxUDPManager auxCxnUdp;
//ofxTCPClient auxCxnTcp; ToDo
AuxInstrQ *appQ; ///< pointer to main application queue

/*!
* \brief Setup the AUX Cxn
* \return 0 is success, else failure code
*/
std::uint16_t begin();

/*!
* \brief Read the aux port for incoming messages
* \param channel Either UDP or TCP
*/
void readAuxCxn(AuxChannel channel = AuxChannel::CHANNEL_UDP);

/*!
* \brief Parse received UDP/TCP message into packets. Set packet delimiter is used to parse message into packets
* \return Instruction packet(s)
*/
std::vector<std::string> parseMessage(std::string message);


/*!
* \brief push to local queue. All UDP/TCP messages are temporarily stored in this queue before being pushed to the main queue in the application.
* \return true if pushed
*/
bool push(std::string packet);



/*!
* \brief pop queue element.
* \return True if queue is not empty.
*/
bool pop(std::string &packet);

/*!
* \brief Pushes all messages from local controller queue to main application queue
* \return true is successful
*/
bool pushToAppQ();

/**
* \brief Function called in ofApp during setup to pass main application queue pointer to this controller.
*
* \param q pointer to main application queue
* \return true if pointer is not null
*/
bool attachAppQ(AuxInstrQ *q);

private:

std::queue<std::string> bufferQ; ///< Local queue to buffer UDP/TCP messages before pushing into the main application queue

};
Loading
Loading