printf raw data — get printf or print to NOT send characters
-
27-10-2019 - |
题
I have a Xilinx Virtex-II Pro FPGA board that is attached via RS232 to an iRobot Create.
The iRobot takes a stream of byte integers as commands.
I've found that printf will actually send over the serial port (Hypterminal is able to pick up whatever I print), and I figure that I can use printf to send my data to the iRobot.
The problem is that printf seems to format the data for ascii output, but I'd REALLY like it to simply send out the data raw.
I'd like something like:
printf(%x %x %x, 0x80, 0x88, 0x08);
But instead of the hexadecimal getting formatted, I'd like it to be the actual 0x80 value sent.
Any ideas?
其他提示
Use the format "%c%c%c"
instead.
You would use fwrite instead. Printf is by definition an ascii printer.
char buf[] = {0x80, 0x80, 0x80};
fwrite(buf, 1, 3, stdout);
seems to be what you want.
不隶属于 StackOverflow