fixed and enhanced PlusROM hotspot handling

This commit is contained in:
Thomas Jentzsch 2021-10-04 10:13:16 +02:00
parent a2eb62402f
commit f239f140a9
1 changed files with 37 additions and 18 deletions

View File

@ -32,8 +32,13 @@
namespace { namespace {
constexpr int MAX_CONCURRENT_REQUESTS = 5; constexpr int MAX_CONCURRENT_REQUESTS = 5;
constexpr int CONNECTION_TIMEOUT_MSEC = 3000; constexpr int CONNECTION_TIMEOUT_MSEC = 3000;
constexpr int READ_TIMEOUT_MSEC = 3000; constexpr int READ_TIMEOUT_MSEC = 3000;
constexpr int WRITE_TIMEOUT_MSEC = 3000; constexpr int WRITE_TIMEOUT_MSEC = 3000;
constexpr uInt16 WRITE_TO_BUFFER = 0x1FF0;
constexpr uInt16 WRITE_SEND_BUFFER = 0x1FF1;
constexpr uInt16 RECEIVE_BUFFER = 0x1FF2;
constexpr uInt16 RECEIVE_BUFFER_SIZE = 0x1FF3;
} }
#endif #endif
@ -208,25 +213,32 @@ bool PlusROM::initialize(const ByteBuffer& image, size_t size)
bool PlusROM::peekHotspot(uInt16 address, uInt8& value) bool PlusROM::peekHotspot(uInt16 address, uInt8& value)
{ {
#if defined(HTTP_LIB_SUPPORT) #if defined(HTTP_LIB_SUPPORT)
switch(address & 0x0FFF) switch(address & 0x1FFF)
{ {
case 0x0FF2: // Read next byte from Rx buffer // invalid reads from write addresses
receive(); case WRITE_TO_BUFFER: // Write byte to Tx buffer
myTxBuffer[myTxPos++] = address & 0xff; // TODO: value is undetermined
break;
case WRITE_SEND_BUFFER: // Write byte to Tx buffer and send to backend
// (and receive into Rx buffer)
myTxBuffer[myTxPos++] = address & 0xff; // TODO: value is undetermined
send();
break;
// valid reads
case RECEIVE_BUFFER: // Read next byte from Rx buffer
receive();
value = myRxBuffer[myRxReadPos]; value = myRxBuffer[myRxReadPos];
if (myRxReadPos != myRxWritePos) myRxReadPos++; if (myRxReadPos != myRxWritePos) myRxReadPos++;
return true; return true;
case 0x0FF3: // Get number of unread bytes in Rx buffer case RECEIVE_BUFFER_SIZE: // Get number of unread bytes in Rx buffer
receive(); receive();
value = myRxWritePos - myRxReadPos; value = myRxWritePos - myRxReadPos;
return true; return true;
} }
#endif #endif
return false; return false;
} }
@ -234,23 +246,30 @@ bool PlusROM::peekHotspot(uInt16 address, uInt8& value)
bool PlusROM::pokeHotspot(uInt16 address, uInt8 value) bool PlusROM::pokeHotspot(uInt16 address, uInt8 value)
{ {
#if defined(HTTP_LIB_SUPPORT) #if defined(HTTP_LIB_SUPPORT)
switch(address & 0x0FFF) switch(address & 0x1FFF)
{ {
case 0x0FF0: // Write byte to Tx buffer // valid writes
case WRITE_TO_BUFFER: // Write byte to Tx buffer
myTxBuffer[myTxPos++] = value; myTxBuffer[myTxPos++] = value;
return true; return true;
case 0x0FF1: // Write byte to Tx buffer and send to backend case WRITE_SEND_BUFFER: // Write byte to Tx buffer and send to backend
// (and receive into Rx buffer) // (and receive into Rx buffer)
myTxBuffer[myTxPos++] = value; myTxBuffer[myTxPos++] = value;
send(); send();
return true; return true;
// invalid writes to read addresses
case RECEIVE_BUFFER: // Read next byte from Rx buffer
receive();
if(myRxReadPos != myRxWritePos) myRxReadPos++;
break;
case RECEIVE_BUFFER_SIZE: // Get number of unread bytes in Rx buffer
receive();
break;;
} }
#endif #endif
return false; return false;
} }