This Script can be used to send non ascii strings over the serial interface. This is ussually made to talk to external devices for managment or configuration.
The Big diffrence is to define the non ascii String as follows
get_status="\xBF\xEF\x12\x00\x21"; set_power_mode="\xBF\xBC\x23\x00\x3F";
and use the write() function to send them over the serial port
/* Serial Baud Rate 9600, 19200, 38400, 57600, 115200 */ SER_SPEED=115200; /* number of data bits (5, 6, 7, 8) */ SER_DATABIT=8; /* number of stop bits (1, 2) */ SER_STOPBIT=1; /* parity (0=no parity, 1=odd parity, 2=even parity) */ SER_PARITY=0; /* flow control (0=none, 1=xon/xoff, 2=hardware) */ SER_FLOW=0; /* name of the Serial Interface (Only changed if your device has more then one serial Interface (NB3710) */ DEV = "SERIAL1"; rc = nb_serial_setattr(DEV, SER_SPEED, SER_DATABIT, SER_STOPBIT, SER_PARITY, SER_FLOW); if (rc != 0) { nb_syslog("ERROR: unable to set serial attributes (rc %d)", rc); return -1; } /* open serial port */ serial_fd = nb_serial_open(DEV); if (fd < 0) { return -1; } get_status="\xBF\xEF\x12\x00\x21"; set_power_mode="\xBF\xBC\x23\x00\x3F"; data=get_status; len=strlen(data); if (len > 0) { sent = write(serial_fd, data, len); if (sent != len) { nb_syslog("Unable to send message via Serial, sent: %i, len: %i",sent, len); } }