Hello
I can communicate with a python script using a shell and using .writeline to send strings to the python script and get a response back. I wonder if there is a more efficient way of doing it rather than strings since I want to send RGB colours and so sending bytes I think would be better. Is it possible using a shell or should I be looking at sockets or something else. (I am used to sending UDP packets between python scripts but I haven’t done anything like this with Xojo)
Is there another way and some examples?
If you’re just talking about RGB colors, they’re very efficiently expressed as hex values -.#RRGGBB is the common format on the web. You’d only save three bytes by encoding them as binary. Is that really worth the hassle?
Isn’t that 7 ascii characters and therefore 7 bytes? I am sending 10 rgb values so doesn’t that equate to 40 extra bytes? I thought a string is a byte per character.
you could try a memory block.
instead of byte array xojo often use a string argument for methods.
see example at Byte(offset As Integer…
if you like a independent running python script you can connect via TCP.
(TCP Server Listen at Port xz/TCP Client Connect)
few lines of code in python.
Thanks. A memory block seems to work.
You’re correct.
Still, it’s only 40 extra bytes for 10 colors. Now I’m very curious why you are so concerned about such s tiny amount of data.
Well it’s more about educating myself. I’m new to Xojo and if I ever need to do anything with BLE, which I believe has a 20 byte payload limit (or something like that) then this is the sort of thing I need to know. I’m also thinking of how to wrap information into bytes and extracting it with bitwise operations and how to make it efficient. At some point I’m going to create a protocol for an RS485 network which would benefit from minimal traffic. I know it’s pedantic but I am sure it will be good for my brain.
Ah! Those are all excellent reasons to economize your data transmissions. It never hurts to make things smaller and more efficient.
I will point out that BLE is routinely used for tethering devices to cell phones so they are used for pretty significant transfers, and some implementations have a much larger payload size. All things being equal, this isn’t where I would start if you are looking to speed things up.