Skip to content

Commit eb5c9e2

Browse files
moved the output buffer out of the BSS section to resolve a bss size issue in some of the platform builds.
1 parent 271bb35 commit eb5c9e2

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

‎include/output/OutputMgr.hpp‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ class c_OutputCommon; ///< forward declaration to the pure virtual output class
3737

3838
class c_OutputMgr
3939
{
40+
private:
41+
#ifdef ARDUINO_ARCH_ESP8266
42+
#define OM_MAX_NUM_CHANNELS (1200 * 3)
43+
#else // ARDUINO_ARCH_ESP32
44+
#define OM_MAX_NUM_CHANNELS (3000 * 3)
45+
#endif // !def ARDUINO_ARCH_ESP32
46+
4047
public:
4148
c_OutputMgr ();
4249
virtual ~c_OutputMgr ();
@@ -51,9 +58,9 @@ class c_OutputMgr
5158
void SetConfig (ArduinoJson::JsonDocument & NewConfig); ///< Save the current configuration data to nvram
5259
void GetStatus (JsonObject & jsonStatus);
5360
void GetPortCounts (uint16_t& PixelCount, uint16_t& SerialCount) {PixelCount = uint16_t(OutputChannelId_End); SerialCount = uint16_t(NUM_UARTS); }
54-
uint8_t* GetBufferAddress () { return OutputBuffer; } ///< Get the address of the buffer into which the E1.31 handler will stuff data
61+
uint8_t* GetBufferAddress () { return pOutputBuffer; } ///< Get the address of the buffer into which the E1.31 handler will stuff data
5562
uint32_t GetBufferUsedSize () { return UsedBufferSize; } ///< Get the size (in intensities) of the buffer into which the E1.31 handler will stuff data
56-
uint32_t GetBufferSize () { return sizeof(OutputBuffer); } ///< Get the size (in intensities) of the buffer into which the E1.31 handler will stuff data
63+
uint32_t GetBufferSize () { return uint32_t(OM_MAX_NUM_CHANNELS); } ///< Get the size (in intensities) of the buffer into which the E1.31 handler will stuff data
5764
void DeleteConfig () { FileMgr.DeleteFlashFile (ConfigFileName); }
5865
void PauseOutputs (bool NewState);
5966
void GetDriverName (String & Name) { Name = "OutputMgr"; }
@@ -197,12 +204,6 @@ class c_OutputMgr
197204
OutputType_Start = OutputType_Disabled,
198205
};
199206

200-
#ifdef ARDUINO_ARCH_ESP8266
201-
# define OM_MAX_NUM_CHANNELS (1200 * 3)
202-
#else // ARDUINO_ARCH_ESP32
203-
# define OM_MAX_NUM_CHANNELS (3000 * 3)
204-
#endif // !def ARDUINO_ARCH_ESP32
205-
206207
enum OM_PortType_t
207208
{
208209
Uart = 0,
@@ -255,7 +256,7 @@ class c_OutputMgr
255256

256257
String ConfigFileName;
257258

258-
uint8_t OutputBuffer[OM_MAX_NUM_CHANNELS];
259+
uint8_t pOutputBuffer = nullptr;
259260
uint32_t UsedBufferSize = 0;
260261

261262
#ifndef DEFAULT_CONSOLE_TX_GPIO

‎src/output/OutputMgr.cpp‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ c_OutputMgr::c_OutputMgr ()
211211
ConfigFileName = String ("/") + String (CN_output_config) + CN_Dotjson;
212212

213213
// clear the input data buffer
214-
memset ((char*)&OutputBuffer[0], 0, sizeof (OutputBuffer));
214+
pOutputBuffer = (uint8_t*)malloc(GetBufferSize() + 1);
215+
memset (pOutputBuffer, 0, GetBufferSize());
215216
for (DriverInfo_t & CurrentOutput : OutputChannelDrivers)
216217
{
217218
memset (CurrentOutput.OutputDriver, 0, sizeof (CurrentOutput.OutputDriver));
@@ -284,7 +285,7 @@ void c_OutputMgr::Begin ()
284285
// CreateNewConfig();
285286

286287
// Preset the output memory
287-
memset((void*)&OutputBuffer[0], 0x00, sizeof(OutputBuffer));
288+
memset(pOutputBuffer, 0x00, GetBufferSize());
288289

289290
} while (false);
290291

@@ -391,7 +392,7 @@ void c_OutputMgr::CreateNewConfig ()
391392
// DEBUG_V ();
392393

393394
JsonWrite(JsonConfig, CN_cfgver, ConstConfig.CurrentConfigVersion);
394-
JsonWrite(JsonConfig, CN_MaxChannels, sizeof(OutputBuffer));
395+
JsonWrite(JsonConfig, CN_MaxChannels, GetBufferSize());
395396

396397
// DEBUG_V("Collect the all ports disabled config first");
397398
CreateJsonConfig (JsonConfig);
@@ -1451,12 +1452,12 @@ void c_OutputMgr::UpdateDisplayBufferReferences (void)
14511452

14521453
CurrentOutput.OutputBufferStartingOffset = OutputBufferOffset;
14531454
CurrentOutput.OutputChannelStartingOffset = OutputChannelOffset;
1454-
((c_OutputCommon*)CurrentOutput.OutputDriver)->SetOutputBufferAddress(&OutputBuffer[OutputBufferOffset]);
1455+
((c_OutputCommon*)CurrentOutput.OutputDriver)->SetOutputBufferAddress(pOutputBuffer + OutputBufferOffset);
14551456

14561457
uint32_t OutputBufferDataBytesNeeded = ((c_OutputCommon*)CurrentOutput.OutputDriver)->GetNumOutputBufferBytesNeeded ();
14571458
uint32_t VirtualOutputBufferDataBytesNeeded = ((c_OutputCommon*)CurrentOutput.OutputDriver)->GetNumOutputBufferChannelsServiced ();
14581459

1459-
uint32_t AvailableChannels = sizeof(OutputBuffer) - OutputBufferOffset;
1460+
uint32_t AvailableChannels = GetBufferSize() - OutputBufferOffset;
14601461

14611462
if (AvailableChannels < OutputBufferDataBytesNeeded)
14621463
{

0 commit comments

Comments
 (0)