- Notifications
You must be signed in to change notification settings - Fork0
MTConnect Adapter acting as a relay for a device sending SHDR data on serial port
License
Demo-Smart-Factory-Concordia-University/MTCAdapterRelay
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
MTConnect Adapter acting as a relay for a physical device (e.g. a sensor) sending SHDR data on the serial port.
The MTCAdapterReay allows to hock up a device capable of sending SHDR data on the serial port butnot capable of sending TCP/IP data to an MTConnect Agent.
The MTCAdapterRelay is a small Python library desinged to work together with theMTConnect cpp agent.
Two classes need to be defined: anMTCAdapterRelayHandler
and aMTCAdapterRelay
class.
TheMTCAdapterRelayHandler
is responsible to define the proper parameters for communicating with thedevice over the serial port.
At minimum the 'serial_port' attribute must be defined. It is the name of the Linux device fileto access the serial port (e.g./dev/ttyUSB1
).
Further the following attributes may have to be redfined to match the configuration of the used serial port:
baudrate = 115200parity = serial.PARITY_NONEbytesize = serial.EIGHTBITSstopbits = serial.STOPBITS_ONE
TheMTCAdapterRelay
class is a specialized TCP/IP server which implements the PING/PONG hearthbeat convention oftheMTConnect cpp agent.
The attributeadapter_port
(default value 7878) holds the port number on which the adapter relay will run.
The attributedeviceHandler_class
must contain theMTCAdapterRelayHandler
class defining the correctserial port paramters to communicate with the device.
A typical example looks like this(this is an example for a temperature sensor connected via an Arduino type device.The Arduino sketch is availblehere):
from mtcadapterrelay import MTCAdapterRelay, MTCAdapterRelayHandlerimport sysclass DS18B20_MTCAdapterRelayHandler(MTCAdapterRelayHandler): serial_port = '/dev/ttyUSB1' baudrate = 115200 parity = serial.PARITY_NONE bytesize = serial.EIGHTBITS stopbits = serial.STOPBITS_ONEclass DS18B20_MTCAdapterRelay(MTCAdapterRelay): adapter_port = 8881 deviceHandler_class = DS18B20_MTCAdapterRelayHandler myAdapter = DS18B20_MTCAdapterRelay()try: myAdapter.serve_forever()except KeyboardInterrupt: sys.exit(0)
About
MTConnect Adapter acting as a relay for a device sending SHDR data on serial port
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.