2019-11-19 08:05 PM
Hello,
I have project currently running in the simulator only. One screen consists of a swipe container with several pages, in the swipe container is a scroll list. I've created a custom container for the scroll list and one of those widgets is textArea. The text area contains one wild card. I've unchecked Auto-size for the text area, set the text as <v>, selected Wildcard 1 as single use, checked Use WIldcard Buffer and set an initial value. In Typographies, I've set the Wildcard Ranges for that typography as 0x20-0x7E. I use the following code in my screenView.cpp
void settingsScreenView::portSelectListUpdateItem(listItemContainer& item, int16_t itemIndex)
{
uint16_t buffer[32];
uint8_t size = 32;
if(itemIndex >= 0 && itemIndex < PORT_MAX)
{
presenter->getPortString(itemIndex, buffer, size);
}
else
{
Unicode::snprintf(buffer, size, "STRING_ERROR");
}
touchgfx_printf("buffer: %s, size: %d, itemIndex: %d\n", buffer, size, itemIndex);
item.setValue(buffer, size);
portSelectList.invalidate();
}
and the following code in my container.cpp
void listItemContainer::setValue(uint16_t* buffer, uint8_t size)
{
Unicode::strncpy(listItemTextBuffer, buffer, LISTITEMTEXT_SIZE);
touchgfx_printf("listItemContainer - listItemTextBuffer: %s\n", listItemTextBuffer);
}
Everything compile, links and runs but I get the following behavior with the text:
But the output of the touchgfx_printf() calls indicate all is copying well
Because I'm seeing question marks, I assume it is a typography issue, but even if I change the fallback character to blank (should generate an exception), I get no exception and no change in behavior. The text that is printed is consistent from run to run, so that leads me to believe it isn't a pointer that points to garbage issue, but maybe that's a bad assumption?
TouchGFX version is 4.12.3
Thanks,
Andy
Solved! Go to Solution.
2019-11-19 08:38 PM
Probably should have done some more debugging before I posted. Issue was in the presenter code (not listed in original post)
presenter.cpp
void settingsScreenPresenter::getPortString(uint16_t index, uint16_t* buffer, uint8_t size)
{
Unicode::snprintf(buffer, size, "%s", portStringList[index]);
}
should be
void settingsScreenPresenter::getPortString(uint16_t index, uint16_t* buffer, uint8_t size)
{
Unicode::strncpy(buffer, portStringList[index], size);
}
making it an issue of the null terminating character not being correct, with the touchgfx_printf() and Windows console print somehow being able to figure it out
Foiled by printf() again!!!!!!!!!!!!
2019-11-19 08:15 PM
UPDATE: It does seem to be a typography issue. I set the fallback character to blank and did a make clean and a generate code and then run simulator and got an exception on 'R', which is in the range. Not sure what exactly I'm doing wrong.
2019-11-19 08:38 PM
Probably should have done some more debugging before I posted. Issue was in the presenter code (not listed in original post)
presenter.cpp
void settingsScreenPresenter::getPortString(uint16_t index, uint16_t* buffer, uint8_t size)
{
Unicode::snprintf(buffer, size, "%s", portStringList[index]);
}
should be
void settingsScreenPresenter::getPortString(uint16_t index, uint16_t* buffer, uint8_t size)
{
Unicode::strncpy(buffer, portStringList[index], size);
}
making it an issue of the null terminating character not being correct, with the touchgfx_printf() and Windows console print somehow being able to figure it out
Foiled by printf() again!!!!!!!!!!!!