[chbot] HEX and ANSII ATMEGA and Delphi

Mark Atherton markaren1 at xtra.co.nz
Sat Oct 24 00:27:18 BST 2020


How about starting off by finding out what the appropriate Delphi 
read-number routine requires,  then use this definition to craft the 
complementary send number in the Arduino ?

On 24/10/2020 11:00 AM, Andrew Errington wrote:
> Hi Wallace,
> 
> What are you trying to do? It sounds like you want to dump the value of 
> tcnt1, a 16-bit register, from the serial port and reconstruct it in Delphi.
> 
> When it arrives in Delphi do you want it to be an unsigned int, or a string?
> 
> Since you are in control of both ends you can do whatever is easiest. As 
> far as I can see you could serialise the source value to a string of 
> ASCII digits, either hex or decimal and send those (hex is shorter, e.g. 
> FFFF is "FFFF", 4 characters in hex or "65535", 5 characters in 
> decimal). Or you can send two bytes verbatim, e.g. 0xFF 0xFF, 2 
> characters only.
> 
> You probably want a start and end marker too, so the receiver knows how 
> to split up the incoming data stream. If you are sending a string 
> usually you can use \n as an end marker.
> 
> The receiving end has to know the format of the incoming data, then read 
> each character and decide what it means.
> 
> If you only want a human-readable output and you are sending a string 
> then you are done. Otherwise you need to get the first verbatim byte, 
> shift it left, then OR in the second byte to build a 16-bit value. Once 
> you have this 16-bit value you can do what you like with it.
> 
> HTH,
> 
> Andrew
> 
> 
> On Sat, 24 Oct 2020, 10:28 Andrew Starr, <ajstarr at gmail.com 
> <mailto:ajstarr at gmail.com>> wrote:
> 
>     Hi Wallace,
> 
>     There is support for base64 in the Arduino libraries (if you're using
>     them). But with base64 you're encoding 3 bytes with 4, so if you're
>     only
>     sending a single byte per transaction it probably isn't much use to
>     you.
>     A LUT would certainly be faster, although you're trading code space for
>     speed - depends on what your priorities are.
> 
>     Cheers
> 
>     On 24/10/20 10:16 am, Marshland Engineering wrote:
>      > Hi Andrew.
>      >
>      > Thanks for the reply. I've just done a few c programs for my own
>     use so not so
>      > great on this.
>      > First time I have heard of base64.  Basically I want to send the
>     value of the
>      > tcnt1 to the PC.
>      >
>      >  From my reading on base64, it looks like I have to create my own
>     routine for
>      > this ?
>      >
>      > Now that you have got me thinking, I can just create my own look
>     up table and
>      > convert HEX 1,2-F into string "1", "2" etc. That is quite easy
>     and I can then
>      > send data separator characters as well.
>      >
>      > Thanks Wallace
>      >
> 
> 
>     _______________________________________________
>     Chchrobotics mailing list Chchrobotics at lists.ourshack.com
>     <mailto:Chchrobotics at lists.ourshack.com>
>     https://lists.ourshack.com/mailman/listinfo/chchrobotics
>     Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/
>     Meetings usually 3rd Monday each month. See http://kiwibots.org for
>     venue, directions and dates.
>     When replying, please edit your Subject line to reflect new subjects.
> 
> 
> _______________________________________________
> Chchrobotics mailing list Chchrobotics at lists.ourshack.com
> https://lists.ourshack.com/mailman/listinfo/chchrobotics
> Mail Archives: http://lists.ourshack.com/pipermail/chchrobotics/
> Meetings usually 3rd Monday each month. See http://kiwibots.org for venue, directions and dates.
> When replying, please edit your Subject line to reflect new subjects.
> 




More information about the Chchrobotics mailing list