I'm currently stuck on a small problem....I know the solution should not be too hard to come by, but I just can't figure it out....
I'm working on an application that communicates with a piece of hardware through the serial port. The communication's up and running, no problems there. There is one problem though, I need to be able to set the time and date of the hardware, and the hardware expects that in bcd (binary coded decimal). The communication expects bytes.
I've written a conversion function, that takes an integer value, and returns a string, which contains a two-digit bcd code. What I want is to convert that string to a byte, and send that byte to the serialport, without any more calculation, to be sure I don't lose the bcd value.
If anyone can think of a better way, I'd love to hear it, this is getting silly!
In my opinion it should be possible to just create a byte out of the two sets of 4 bits the bcd code is made up of, but I'm creating my own blind spots or something...