Category : struct

Is there a possibility to access structure elemenents from a function inside the structure. E.g something comparable to the self.arg which I’m used from python? To give a minimal example I want to link the functions to the structure and run a script which takes the structure elements as parameters. Is there a way to ..

Read more

I’ve been porting some C code [FANUC FOCAS Library] to Python using ctypes. In one of the most complex Struct I have to porting, I am not able to catch all the variables’ values and I am not being able to find out the reasons. In C (from FANUC’s fwlib32.h) typedef struct speedelm { long ..

Read more

I need to write a python call that has a callback that will be invoked by C function. But when i’m doing it i got a Segmentation fault (core dumped) error. The C header file has the following: typedef struct Callback_Struct { void(*callback1)(unsigned short param1, int param2); void(*callback2)(unsigned short param1, int param2); } CallBack, *PCallBack; ..

Read more

I would like to filter two ordered arrays in a struct that has fields dates, and values. Example DataFrame below followed by and explanation and an example of what I am trying to do. from pyspark.sql import Row import datetime rows = [ Row( id =’1111′, A=Row( dates=[datetime.datetime(2015, 7, 29, 14, 27), datetime.datetime(2015, 7, 31, ..

Read more

input: print(struct.pack("b", 0) print(struct.pack("b", 0)) print(struct.pack("I", 3)) print(struct.pack("I", 0)) print(struct.pack("I", 0)) print((struct.pack(‘bbIII’, 0, 0, 3, 0, 0))) output: b’x00′ b’x00′ b’x03x00x00x00′ b’x00x00x00x00′ b’x00x00x00x00′ b’x00x00x00x00x03x00x00x00x00x00x00x00x00x00x00x00′ Singed chars at the last row are returning 2bytes for some reason.I don’t understand why the last bytearray is returning the longer value than what I expect, I would like to ..

Read more

I’m porting some of the code of iridium-toolkit’s reassembler from Python 2 to Python 3, got stuck trying to fix the type mix in the struct.pack invocations. Using gsm=struct.pack("!BBBBHbBLBBBB",2,4,2,0,0×4000+fchan,olvl,0,freq,1,0,0,0)+lapdm.encode() actually (kinda) works but the generated pcap file contains malformed packets. Abusing the type mix in Python 2 does the right thing and builds a correct ..

Read more