This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to transmit binary data and floating point data result to RS232 serial com

Hi all ,

I would like to know the method of transmitting 16bit binary data (from 8255 port A & B) and floating point ouput result using serial comm(rs232) from 8051 to pc. i know we can use printf method. But if i want to use SBUF method, should i convert the binary data or the floating point calculated result using sprintf method and transmit the buf (from sprintf) to SBUF.

your help is much appreciated.

thanks

Parents
  • "i know we can use printf method. But if i want to use SBUF method..."

    Just to be clear, the printf() method does use the SBUF method, as ends up calling putchar(), which outputs characters using SBUF.

    "...should i convert the binary data or the floating point calculated result using sprintf method and transmit the buf (from sprintf) to SBUF."

    Sure you can do that, but it ends up not being a whole lot different than printf() from the standpoint of binary-to-ASCII conversion. However, it does allow you the flexibility to tailor your output methods (e.g., interrupt-driven output if you want).

    But back to the post's title "How to transmit binary...", if you are trying to avoid all the overhead of binary-to-ASCII conversions (including floating point conversions), you can transmit the data just as it "appears" in memory. You just need to frame the data so that the receiving end know where the binary data begins and ends and what type of data is contained in the frame (so it can distinguish, for example, a 16-bit integer from a 32-bit floating point number).

    There are a couple of documents (hdlcbcc.pdf and tinyrpc.pdf) on http://dhenry.home.sprynet.com that describe a simple binary framing protocol (HDLC BCC 15.1) and a tiny RPC-like call/reply protocol that might give you some ideas if you are truly trying to do binary comms.

Reply
  • "i know we can use printf method. But if i want to use SBUF method..."

    Just to be clear, the printf() method does use the SBUF method, as ends up calling putchar(), which outputs characters using SBUF.

    "...should i convert the binary data or the floating point calculated result using sprintf method and transmit the buf (from sprintf) to SBUF."

    Sure you can do that, but it ends up not being a whole lot different than printf() from the standpoint of binary-to-ASCII conversion. However, it does allow you the flexibility to tailor your output methods (e.g., interrupt-driven output if you want).

    But back to the post's title "How to transmit binary...", if you are trying to avoid all the overhead of binary-to-ASCII conversions (including floating point conversions), you can transmit the data just as it "appears" in memory. You just need to frame the data so that the receiving end know where the binary data begins and ends and what type of data is contained in the frame (so it can distinguish, for example, a 16-bit integer from a 32-bit floating point number).

    There are a couple of documents (hdlcbcc.pdf and tinyrpc.pdf) on http://dhenry.home.sprynet.com that describe a simple binary framing protocol (HDLC BCC 15.1) and a tiny RPC-like call/reply protocol that might give you some ideas if you are truly trying to do binary comms.

Children