Description

Sends a byte-based command to the Commander core device through the open path device, which is specified in the parameter pHandle and reads the response from the device. The command to be sent must be passed as a byte array in parameter command. The response byte array received from the device is stored in reply. Returns 1 if successful, 0 if unsuccessful.

The command buffer must be smaller than 64 bytes in length.

The reply buffer must be at least 63 bytes in length.

Arguments

pHandle

Type: CommanderDeviceHandle*  

Pointer to a device‑handle variable.

command

Type: uint8_t*  

ASCII command byte array to be sent to the Commander.

command_length

Type: size_t*  

Length of buffer in command.

reply

Type: uint8_t*  

Buffer to receive the response from the Commander.

reply_length

Type: size_t*  

Number of bytes to read from Commander.

The default length should be set to 63 to receive a full reply.


Return Value

Type: Int  


Value

Meaning

0

Failure

1

Success

Other (negative)

Host communication failed (see Communication Error Codes)


Examples

  • Python

api = DLLInterface()

# Send and Receive Bytes Commander

command = list('VER'.encode("utf-8"))

ByteArray = ctypes.c_ubyte * len(command)

command_array = ByteArray(*command)

reply = ctypes.create_string_buffer(64)  # Allocate buffer for the reply

return = api.dll.SendReceiveBytesCommander(self.handle, command_array, len(command), reply, ctypes.sizeof(reply))

if return:

   dataStr = "".join([chr(byte) for byte in reply.raw if byte != 0]) # Convert to string, ignoring null bytes

   print(f"Sent: {command}, Received: {dataStr}")


REPOSITORY PLACEHOLDER LINK

< Previous | Topic Home | Home |  Next  >