Skip to content

Commit

Permalink
reduced baud rates for S3 UART, handle data errors on the ESP32
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalkbrenner committed Jan 25, 2025
1 parent 3e129a6 commit ecd9e3d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions src/ZeDMDComm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void ZeDMDComm::Run()
Log("ZeDMD StreamBytes failed");

// Allow ZeDMD to empty its buffers.
std::this_thread::sleep_for(std::chrono::milliseconds(2));
std::this_thread::sleep_for(std::chrono::milliseconds(16));
}
}

Expand Down Expand Up @@ -596,6 +596,7 @@ void ZeDMDComm::SoftReset()
bool ZeDMDComm::StreamBytes(ZeDMDFrame* pFrame)
{
static uint8_t payload[36864] = {0};
memset(payload, 0, 36864);
memcpy(payload, FRAME_HEADER, FRAME_HEADER_SIZE);
uint16_t pos = FRAME_HEADER_SIZE;

Expand Down Expand Up @@ -694,6 +695,7 @@ bool ZeDMDComm::SendChunks(uint8_t* pData, uint16_t size)
if (status < toSend)
{
m_fullFrameFlag.store(true, std::memory_order_release);
Log("Full frame forced, error %d", status);
return false;
}
else if (status < m_writeAtOnce)
Expand All @@ -711,9 +713,16 @@ bool ZeDMDComm::SendChunks(uint8_t* pData, uint16_t size)

ack[0] = 0;
status = sp_blocking_read(m_pSerialPort, ack, sizeof(ack), ZEDMD_COMM_SERIAL_READ_TIMEOUT);
if (ack[0] != 'A')
if (ack[0] == 'F')
{
m_fullFrameFlag.store(true, std::memory_order_release);
Log("Full frame requested by ZeDMD because of internal error");
return false;
}
else if (ack[0] != 'A')
{
m_fullFrameFlag.store(true, std::memory_order_release);
Log("Full frame forced, error %d", status);
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ZeDMDComm.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#endif

#define ZEDMD_COMM_BAUD_RATE 921600
#define ZEDMD_S3_COMM_BAUD_RATE 2000000
#define ZEDMD_S3_COMM_BAUD_RATE 921600
#define ZEDMD_COMM_MAX_SERIAL_WRITE_AT_ONCE 1024

#define ZEDMD_COMM_SERIAL_READ_TIMEOUT 16
Expand Down

0 comments on commit ecd9e3d

Please sign in to comment.