# Imports from PyTrinamicMicro.platforms.motionpy.connections.usb_vcp_tmcl_interface import usb_vcp_tmcl_interface from PyTrinamicMicro.platforms.motionpy.tmcl_slave_dummy import tmcl_slave_dummy from PyTrinamicMicro import PyTrinamicMicro import struct import logging # Prepare Logger PyTrinamicMicro.set_logging_console_enabled(False) logger = logging.getLogger(__name__) logger.info("TMCL Slave on USB_VCP interface") # Main program lin = None logger.info("Initializing interface ...") con = usb_vcp_tmcl_interface() slave = tmcl_slave_dummy() logger.info("Interface initialized.") while (not (slave.status.stop)): # Handle connection if (con.request_available()): logger.debug("Request available.") request = con.receive_request() if (not (slave.filter(request))): continue logger.debug("Request for this slave detected.") reply = slave.handle_request(request) con.send_reply(reply) logger.info("Closing interface ...")
@author: LK ''' from PyTrinamicMicro import PyTrinamicMicro from PyTrinamicMicro.connections.tmcl_host_interface import tmcl_host_interface from PyTrinamicMicro.platforms.motionpy.connections.rs232_tmcl_interface import rs232_tmcl_interface from PyTrinamicMicro.platforms.motionpy.connections.usb_vcp_tmcl_interface import usb_vcp_tmcl_interface from PyTrinamicMicro.TMCL_Bridge import TMCL_Bridge import logging # Prepare Logger PyTrinamicMicro.set_logging_console_enabled(False) logger = logging.getLogger(__name__) logger.info("TMCL Bridge from USB to RS232") logger.info("Initializing interfaces ...") host = usb_vcp_tmcl_interface() module = rs232_tmcl_interface() bridge = TMCL_Bridge(host, [{"module":module}]) logger.info("Interfaces initialized.") while(not(bridge.process())): pass logger.info("Closing interfaces ...") host.close() module.close() logger.info("Interfaces closed.") logger.info("Bridge stopped.")