Main module

This is the module that handles all the communication with the current Gramophone device.

Gramophone class

class Gramophone.Gramophone(device, verbose=False)[source]

Representation of a Gramophone device.

Parameters:device (usb.core.Device) – The USB device identity
class Parameter(name, info, type)
info

Alias for field number 1

name

Alias for field number 0

type

Alias for field number 2

decode_response(response)[source]

Decodes a response. Returns the error message if the command was not successful and None otherwise.

Parameters:response – The response to decode.
Ptype response:Packet
ping()[source]

Send a ping packet with 5 bytes and print the time the process took.

read_dev_state()[source]

Read the state of the device. The device should be in 0x01 state for usage. The 0x00 state is for setup.

Returns:The device state. ‘Application’ or ‘IAP’
Return type:str
read_firmware_info()[source]

Read the firmware information from the Gramophone. Sets the fimware related variables of the object.

Returns:A dictionary with the firmware info fields in a human readable format.
Return type:dict
read_homing_poition()[source]

The home postion that can be found by homing.

read_homing_state()[source]

0 if the encoder is not trying to find the home position, 1 if it is homing and 2 if the home position was found.

read_sensors()[source]

Returns the values read from the sensors in a dict with the parameter ids as keys.

reset()[source]

Reset the device. Returns None if successful and the error string otherwise.

send(packet)[source]

Sends a Packet to the device.

Parameters:packet – The Packet to send.
Ptype packet:Packet

Helper classes

class Gramophone.Packet(target, source, cmd, payload, msn=None)[source]

A 64 byte data packet that can be sent to the Gramophone.

class Gramophone.GramophoneError[source]

Exception for Gramophone related communication errors.