I'm working with my STM32 but since I'm new to c/c++ (coming from c#) i find string operations a bit difficult.
Until now I'm sending serial like this:
strcpy((char*)buf, "Unable set read MCP9808\r\n");
HAL_UART_Transmit(&huart1, buf, strlen((char*)buf), HAL_MAX_DELAY);
But I want to change that to a onliner using Debug
function that I made. But im getting error 'strlen' from incompatible pointer type
. I want to take inn any string (char array), get its length to set up the buffer and send the data.
int Debug(char arr[])
{
int size = strlen(&arr);
uint8_t buf[size];
strcpy((char*)buf, arr);
// the above code is the important part...
HAL_UART_Transmit(&huart1, buf, strlen((char*)buf), HAL_MAX_DELAY);
return 1;
}
Debug("Hello World!\r\n");