A sniprintf question

Artur Lipowski LAL@pro.onet.pl
Fri Aug 15 03:53:00 GMT 2008


Hi,

Is it expected that sniprintf in subsequent calls somehow "appends" data to 
existing buffer?

E.g.

for (i=0; i<2; i++)
{
  sniprintf(ui_buffer, sizeof(ui_buffer),
   "SSID: %-8s  freq: %lu00Hz  RSSI: %3udB  type: %u  %-6s  MAC: 
%02X:%02X:%02X:%02X:%02X:%02X\n\r",
   (const char*)ssid, freq, rssi, type,
   is_secure ? "secure" : "open",
   mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
  USART_puts(console, ui_buffer);
}

Then output is multiplied (except the last line when i == 1).
If I put:
ui_buffer[0] = '\0';
before sniprintf then output looks good.

BTW> ui_buffer is 256 bytes long, USART_puts is blocking (synchronous) call and 
newlib snapshot is from 25.07.2008


Regards,
-- 
Artur Lipowski



More information about the Newlib mailing list