9 years, 10 months ago.

putc and strange situetion

Hi to all i have this strange situation, i want write on serial communication the Hexadecimal number for use the Modbus RTU communication i write this easy code:

#include "mbed.h"
Serial pc(SERIAL_TX, SERIAL_RX); 
DigitalOut myled(LED2);  
int main() {   
    while(1) {
    myled = !myled;
   pc.putc(0xAA); // work well 
        wait_ms(1000); 
 }
   
}

if i run this code all work well, if i use putty for hiperterminal and i see the the two exadecimal AA but if i use

    pc.putc(0x03); //or
  pc.putc(0x03); 

i don't see nothing. i don't know where is the problem can you help me? A.

1 Answer

9 years, 10 months ago.

Can you try a different terminal program? 0xAA isn't a standard ascii character so putty displays the hex value. 0x03 is a non-printable but valid ascii character. The correct thing for putty to do is not display it.

Can you try something like Hercules? http://www.hw-group.com/products/hercules/index_en.html

Select the serial tab at the top and then right-click and select Special characters->Hexadecimal. All non-printable characters will now be displayed as hex values in {}'s and hopefully you'll see {03} show up in the output.

Accepted Answer

thanks all work well

posted by Antoniolinux B. 12 Jun 2014