Skip to content

Commit

Permalink
RetroShell Commander sends output back to ser:
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkwhoffmann committed Mar 6, 2024
1 parent 8e1e02d commit 3beabd2
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 314 deletions.
13 changes: 13 additions & 0 deletions Emulator/Components/Paula/UART/UART.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,19 @@ UART::rxdHasChanged(bool value)
}
}

void
UART::receiveText(const string &text)
{
{ SYNCHRONIZED

// Add the text
payload += text;

// Start the reception process if needed
if (!agnus.hasEvent<SLOT_RXD>()) agnus.scheduleImm<SLOT_RXD>(RXD_BIT);
}
}

void
UART::recordIncomingByte(int byte)
{
Expand Down
6 changes: 6 additions & 0 deletions Emulator/Components/Paula/UART/UART.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class UART : public SubComponent {
// Bit reception counter
u8 recCnt;

// Experimental
string payload;


//
// Initializing
Expand Down Expand Up @@ -153,6 +156,9 @@ class UART : public SubComponent {
// Called when the RXD port pin changes it's value
void rxdHasChanged(bool value);

// Experimental
void receiveText(const string &text);

private:

// Called when a byte has been received
Expand Down
14 changes: 14 additions & 0 deletions Emulator/Components/Paula/UART/UARTEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ UART::serviceRxdEvent(EventID id)
// Check if this was the last bit to receive
if (recCnt >= packetLength() + 2) {

if (!payload.empty()) {

SYNCHRONIZED

// Overwrite the shift register contents
receiveShiftReg = payload[0];

// Remove the character from the buffer
payload.erase(0, 1);

// Make sure to stop after the last character
rxd = payload.empty();
}

// Copy shift register contents into the receive buffer
copyFromReceiveShiftRegister();
trace(SER_DEBUG, "Received packet %X\n", receiveBuffer);
Expand Down
6 changes: 6 additions & 0 deletions Emulator/Components/Ports/SerialPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,12 @@ SerialPort::readOutgoingPrintableByte()
}
}

void
SerialPort::receiveText(const string &text)
{
uart.receiveText(text);
}

void
SerialPort::recordIncomingByte(int byte)
{
Expand Down
3 changes: 3 additions & 0 deletions Emulator/Components/Ports/SerialPort.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ class SerialPort : public SubComponent {
int readIncomingPrintableByte();
int readOutgoingPrintableByte();

// Experimental
void receiveText(const string &text);

private:

// Called by the UART when a byte has been received or sent
Expand Down
8 changes: 8 additions & 0 deletions Emulator/Misc/RetroShell/InterpreterCmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,14 @@ Interpreter::initCommandShell(Command &root)
amiga.configure(OPT_SER_VERBOSE, parseBool(argv[0]));
});

root.add({"serial", "send"}, { "<text>" },
"Sends a text to the serial port",
[this](Arguments& argv, long value) {

printf("Sending %s\n", argv[0].c_str());
amiga.serialPort.receiveText(argv[0]);
});


//
// Df0, Df1, Df2, Df3
Expand Down
6 changes: 6 additions & 0 deletions Emulator/Misc/RetroShell/RetroShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ RetroShell::operator<<(char value)
{
storage << value;
remoteManager.rshServer << value;
if (serialPort.getConfig().device == SPD_COMMANDER) {
serialPort.receiveText(string{value});
}
needsDisplay();
return *this;
}
Expand All @@ -58,6 +61,9 @@ RetroShell::operator<<(const string& value)
{
storage << value;
remoteManager.rshServer << value;
if (serialPort.getConfig().device == SPD_COMMANDER) {
serialPort.receiveText(value);
}
needsDisplay();
return *this;
}
Expand Down
1 change: 1 addition & 0 deletions Emulator/Misc/RetroShell/TextStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ TextStorage::operator<<(char c)
case '\n':

if (ostream) *ostream << storage.back() << std::endl;

append("");
break;

Expand Down
2 changes: 2 additions & 0 deletions Proxy/AmigaProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,8 @@
- (NSInteger)readIncomingPrintableByte;
- (NSInteger)readOutgoingPrintableByte;

- (void)receiveText:(NSString *)text;

@end


Expand Down
5 changes: 5 additions & 0 deletions Proxy/AmigaProxy.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,11 @@ - (NSInteger)readOutgoingPrintableByte
return [self serial]->readOutgoingPrintableByte();
}

- (void)receiveText:(NSString *)text
{
[self serial]->receiveText([text UTF8String]);
}

@end


Expand Down
Loading

0 comments on commit 3beabd2

Please sign in to comment.