Report Bugs Here

Moderator: Mmiscool

User avatar
By jlbachiochi
#47697 I'm building a string to send out the serial port, my solar controller will respond with a similar string. When I try to add chr(0) to a string it is ignored, however characters after it are added correctly. I suspect this might have to do with some stings being zero terminated. I changed to an array to proceed, but this seems unnecessary.

Also is there a way to enter values as HEX for instance 0x3000 instead of 12288?
User avatar
By cicciocb
#47707 Internally the ESP Basic, the Strings are handled as C++ strings, so '\0' is ignored or considered as end of string.

To enter hex values you can use the function hextoint()

ex:
print hextoint("3000")
User avatar
By jlbachiochi
#48159 OK, so instead of using a string to hold binary data I used an array. When the array is output using "serial2print chr(array(x))", any '0' is not output. ?!?
User avatar
By cicciocb
#48163 Yes I think this is an actual limitation due to the way the strings are internally handled.
This is inherited from the arduino Wstring library .
Probably a patch of the lib is required.