Trust ID PBCEX logo 300x102

Use of struct within Functions

5 years 6 months ago
Mark Phelan
Expert Boarder
Expert Boarder
Posts: 95
More
Topic Author
Use of struct within Functions #4715
I can't use struct within my functions, nor can the module be imported. Is this functionality supported?
5 years 6 months ago
Rutger Koperdraad
Platinum Boarder
Platinum Boarder
Posts: 1566
More
Use of struct within Functions #4718
Hi Mark,

Are you talking about Python scripts? What kind of module do you want to import? What do you want to achieve? You need to supply more details.

regards,
Rutger.

Rutger Koperdraad
Senior Software Engineer

"A reasonable man adapts himself to the world. The unreasonable man persists in trying to adapt the world to himself. All progress, therefore, depends on the unreasonable man." (Bernard Shaw)
5 years 6 months ago
Mark Phelan
Expert Boarder
Expert Boarder
Posts: 95
More
Topic Author
Use of struct within Functions #4719
Yes, Python scripts. I want to use struct to reverse the byte order of some data.
5 years 6 months ago
Rutger Koperdraad
Platinum Boarder
Platinum Boarder
Posts: 1566
More
Use of struct within Functions #4720
Hello Mark,

You're not a man of many words. I have no idea what you mean with struct in this context. But reversing the byte order is standard functionality, see screen shot below.



regards,
Rutger.

Rutger Koperdraad
Senior Software Engineer

"A reasonable man adapts himself to the world. The unreasonable man persists in trying to adapt the world to himself. All progress, therefore, depends on the unreasonable man." (Bernard Shaw)
Attachments:
5 years 6 months ago
Mark Phelan
Expert Boarder
Expert Boarder
Posts: 95
More
Topic Author
Use of struct within Functions #4721
Rutger,

Apologies - very busy at the moment!

I was hoping to use this function:

def reverseBytes(x)
return struct.unpack('<H',struct.pack('>H',x))[0]

But I will try the configuration you've outlined above - the issue may be that the data is not an integer, but HEX.
5 years 6 months ago 5 years 6 months ago by Rutger Koperdraad.
Rutger Koperdraad
Platinum Boarder
Platinum Boarder
Posts: 1566
More
Use of struct within Functions #4722
Don't think you can beat me. You still don't need a struct:



regards,
Rutger.

Rutger Koperdraad
Senior Software Engineer

"A reasonable man adapts himself to the world. The unreasonable man persists in trying to adapt the world to himself. All progress, therefore, depends on the unreasonable man." (Bernard Shaw)
Attachments:
The following user(s) said Thank You Mark Phelan
×

Notice

The forum is in read only mode.