This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/MSP430FR5969: fwrite stops transmitting at NULL-Byte

Part Number: MSP430FR5969

Tool/software: TI C/C++ Compiler

Hello!

For Debugging-Purposes, I am writing binary-data from my MSP430FR5969 to the Console of Code Composer Studio.
I am using fwrite from the stdio-Library, sending everything to stdout.

This works, but the transmission will abort at the position where a NULL-Byte (0x00) should be send. As I know, this would be only an expected behavior when using fputs. Is this a bug, or am I doing s.th. wrong?

I can reproduce this with the following code. (To get any output on the console, I increased the system stack in Linker Options):

/*
 * main.c
 * Uses fwrite to output binary data via stdout to the console of Code Composer Studio, but fails when there are zero-bytes (0x00) in the stream and terminates.
 * Expected result:
 * fwrite should not stop when sending 0x00, this is normaly only done by fput. So the console-Output should be alwas the same length in the following example
 *
 */
#include <stdio.h>
#include <msp430.h>

#define BUFFERLEN 16
unsigned char buf[BUFFERLEN];

int main(void) {
    WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer


    int i=0;
    int zeroBytePlace=0;
    fwrite("Start", 1, 6, stdout);
    while(1){

    	//Init the Buffer with 0xFF, but one Byte with 0x00
    	for(i=0; i<BUFFERLEN; i++){
    		if(i==zeroBytePlace)
    			buf[i]=0x00;
    		else
    			buf[i]=0xFF;
    	}
    	zeroBytePlace =(zeroBytePlace+1)%BUFFERLEN;

    	//Write to Output: Problem: Only the first part of the buffer will be written. At the zeroBytePlace, it will stop
    	fwrite(buf, 1, BUFFERLEN, stdout);
    	fflush(stdout);



    }
	
}

My Compiler version:
TI v15.12.4.LTS

Best regards,

Eiko