0

I am trying to read dynamic data from IC using Cyclone FX programmer/debugger and then also write back data to IC.

I am using python to load dll library and it works successfully. lib = cdll.LoadLibrary(program) I then call function inside of this to connect to the programmer. The function from dll library is: uint32_t connectToCyclone(char *nameIpOrPortIdentifier);

Python:
cyc_name = 'CYC_JF'.encode('utf-8')
cyclonefx = lib.connectToCyclone(cyc_name)

This works ok and I can detect programmer. Now I am using the dll function to read back data from IC: bool startDynamicDataProgram(uint32_t cycloneHandle, uint32_t targetAddress, uint16_t dataLength, char *buffer);

Python:
serial = ''.encode('utf-8')
lib.dynamicReadBytes (cyc_name, 0x08007000, 4, serial)

But my expected output is not correct, which would suggest I am creating my buffer incorrectly.

Question is how to create buffer which can be translated from C into python buffer?

  • https://stackoverflow.com/questions/16699800/python-using-ctypes-to-pass-a-char-array-and-populate-results – Joe Sep 02 '19 at 10:30
  • https://docs.python.org/2/library/ctypes.html#ctypes.c_char_p – Joe Sep 02 '19 at 10:31
  • https://eli.thegreenplace.net/2008/08/31/ctypes-calling-cc-code-from-python – Joe Sep 02 '19 at 10:31
  • https://gist.github.com/nzjrs/990493#file-viactypes-py – Joe Sep 02 '19 at 10:32
  • Possible duplicate of [Python ctypes: How to modify an existing char\* array](https://stackoverflow.com/questions/14310310/python-ctypes-how-to-modify-an-existing-char-array) – CristiFati Sep 02 '19 at 12:05

0 Answers0