SuperHouse / esp-open-rtos

Open source FreeRTOS-based ESP8266 software framework
BSD 3-Clause "New" or "Revised" License
1.53k stars 491 forks source link

Help needed for Serial Communication! #610

Open TMD-Burger opened 6 years ago

TMD-Burger commented 6 years ago

Hello!

Problem: How to send "bytes" over Serial (UART)?

Description: I have a lot of trouble to put a "simple" Byte-Array over Serial. My problem is, there is only one function to send data over Serial: "uart_putc()". But i don´t want to send "chars"., i want to send "bytes".

Example:

const uint8_t dataSize = 3; uint8_t DataArray[dataSize];

void SendData() {
DataArray[0] = 0x7E; DataArray[1] = 100; DataArray[2] = 255;

for (uint8_t i=0, i < dataSize, i++ ) { Send_as_Byte(1, DataArray[i]); } }

or bedder: Send_Bytes(1, DataArray, dataSize);

How i could get this to work ?

Many thanks, Stefan ;-)

rerobika commented 6 years ago

@TMD-Burger If you would like to send byte data in 0x00 - 0xFF range uart_putc is suitable for you. First of all sizeof (char) == sizeof (uint8_t) and in this case does not matter whether your variable is char or uint8_t because this type of information is only used for determining how to interpret the data, but the stored value is always the same in both cases. I hope this explanation helps you.