Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Unreal-Dan committed Sep 5, 2024
1 parent 7cbb0cb commit 887e484
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 8 deletions.
42 changes: 41 additions & 1 deletion VortexEngine/src/Menus/MenuList/EditorConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Menu::MenuAction EditorConnection::run()
case STATE_PULL_EACH_MODE_COUNT:
if (receiveMessage(EDITOR_VERB_PULL_EACH_MODE_ACK)) {
if (Modes::numModes() == 0) {
m_state = STATE_IDLE;
m_state = STATE_PULL_EACH_MODE_DONE;
} else {
m_previousModeIndex = Modes::curModeIndex();
m_state = STATE_PULL_EACH_MODE_SEND;
Expand Down Expand Up @@ -245,6 +245,10 @@ Menu::MenuAction EditorConnection::run()
if (receiveModeCount()) {
// clear modes and start receiving
Modes::clearModes();
// write out an ack
m_receiveBuffer.clear();
SerialComs::write(EDITOR_VERB_PUSH_EACH_MODE_ACK);
// ready to receive a mode
m_state = STATE_PUSH_EACH_MODE_RECEIVE;
}
break;
Expand Down Expand Up @@ -438,6 +442,42 @@ bool EditorConnection::receiveModeCount()
return true;
}

bool EditorConnection::receiveMode()
{
// need at least the buffer size first
uint32_t size = 0;
if (m_receiveBuffer.size() < sizeof(size)) {
// wait, not enough data available yet
return false;
}
// grab the size out of the start
m_receiveBuffer.resetUnserializer();
size = m_receiveBuffer.peek32();
if (m_receiveBuffer.size() < (size + sizeof(size))) {
// don't unserialize yet, not ready
return false;
}
// okay unserialize now, first unserialize the size
if (!m_receiveBuffer.unserialize32(&size)) {
return false;
}
// create a new ByteStream that will hold the full buffer of data
ByteStream buf(m_receiveBuffer.rawSize());
// then copy everything from the receive buffer into the rawdata
// which is going to overwrite the crc/size/flags of the ByteStream
memcpy(buf.rawData(), m_receiveBuffer.data() + sizeof(size),
m_receiveBuffer.size() - sizeof(size));
// clear the receive buffer
m_receiveBuffer.clear();
// unserialize the mode into the demo mode
if (!Modes::addModeFromBuffer(buf)) {
// error
}
return true;
}



bool EditorConnection::receiveDemoMode()
{
// need at least the buffer size first
Expand Down
2 changes: 1 addition & 1 deletion VortexEngine/src/Menus/MenuList/EditorConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class EditorConnection : public Menu
STATE_PUSH_EACH_MODE,
STATE_PUSH_EACH_MODE_COUNT,
STATE_PUSH_EACH_MODE_RECEIVE,
STATE_PULL_EACH_MODE_WAIT,
STATE_PUSH_EACH_MODE_WAIT,
STATE_PUSH_EACH_MODE_DONE,
};

Expand Down
47 changes: 41 additions & 6 deletions VortexEngine/src/VortexConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -481,19 +481,54 @@
// the response from the device when it's done transmitting the mode
#define EDITOR_VERB_TRANSMIT_VL_ACK "n"

// when the pc wants the chromadeck to listen for a mode from the duos
#define EDITOR_VERB_LISTEN_VL "o"
// and the response for when it's done fetching a duo mode
#define EDITOR_VERB_LISTEN_VL_ACK "p"

// pull the duo saveheader via the chromalink
#define EDITOR_VERB_PULL_CHROMA_HDR "q"
// and the response for when it's done fetching the modes
#define EDITOR_VERB_PULL_CHROMA_HDR_ACK "r"

// push the duo save header via the chromalink
#define EDITOR_VERB_PUSH_CHROMA_HDR "s"
// and the response for when it's done pushing the modes
#define EDITOR_VERB_PUSH_CHROMA_HDR_ACK "t"

// pull a duo mode via the chromalink
#define EDITOR_VERB_PULL_CHROMA_MODE "u"
// and the response for when it's done fetching the modes
#define EDITOR_VERB_PULL_CHROMA_MODE_ACK "v"

// push a duo mode via the chromalink
#define EDITOR_VERB_PUSH_CHROMA_MODE "w"
// and the response for when it's done pushing the modes
#define EDITOR_VERB_PUSH_CHROMA_MODE_ACK "x"

// pull a single mode
#define EDITOR_VERB_PULL_SINGLE_MODE "y"
// and the response for when it's done
#define EDITOR_VERB_PULL_SINGLE_MODE_ACK "z"

// push a single mode
#define EDITOR_VERB_PUSH_SINGLE_MODE "A"
// and the response for when it's done
#define EDITOR_VERB_PUSH_SINGLE_MODE_ACK "B"

// the command from the editor to send modes over
#define EDITOR_VERB_PULL_EACH_MODE "o"
#define EDITOR_VERB_PULL_EACH_MODE "C"
// the response from the device when it acknowledges a command
#define EDITOR_VERB_PULL_EACH_MODE_ACK "p"
#define EDITOR_VERB_PULL_EACH_MODE_ACK "D"
// the response from the editor once modes are received
#define EDITOR_VERB_PULL_EACH_MODE_DONE "q"
#define EDITOR_VERB_PULL_EACH_MODE_DONE "E"

// the command from the editor to send modes over
#define EDITOR_VERB_PUSH_EACH_MODE "r"
#define EDITOR_VERB_PUSH_EACH_MODE "F"
// the response from the device when it received the command
#define EDITOR_VERB_PUSH_EACH_MODE_ACK "s"
#define EDITOR_VERB_PUSH_EACH_MODE_ACK "G"
// the response from the device when it received the command
#define EDITOR_VERB_PUSH_EACH_MODE_DONE "t"
#define EDITOR_VERB_PUSH_EACH_MODE_DONE "H"

// ===================================================================
// Manually Configured Sizes
Expand Down

0 comments on commit 887e484

Please sign in to comment.