for instance, I need to take: string macAddr '0013d362b9f3' and convert it to the format shown below for the byte array macAddress. Try to learn how to use character arrays instead and you will avoid running into memory issues. I have written a Wake on Lan routine and I need a way to convert a user entered MAC address into a byte array. You might run into trouble when your programs get bigger and you start using lots of strings. You can look that up in an ASCII table.Īlso remember that, as you are storing this on a byte array, it will only support values from 0 to 255.Īs you are programming on small microcontroller, I would advise against using the String class. I've tested it with gcc 4.4 on RHEL 6 and mingw/gcc 4. Here's a program I just whipped up to create a magic packet from a MAC string. If you are trying to get from a string like "100.150.200.250" to a byte array like. That said, it's still pretty trivial to convert a MAC string to an array of bytes using vanilla C++.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |