Пример #1
0
def request_callback(request):
    global request_command
    request_command = request.command
    return request


def reply_callback(reply):
    if (request_command != TMCL.COMMANDS["GET_FIRMWARE_VERSION"]):
        reply.calculate_checksum()
    return reply


logger.info("Initializing interfaces ...")
host = usb_vcp_tmcl_interface()
modules = [{
    "module": uart_tmcl_interface()
}, {
    "module": can_tmcl_interface(),
    "request_callback": request_callback,
    "reply_callback": reply_callback
}, {
    "module": rs232_tmcl_interface()
}, {
    "module": rs485_tmcl_interface()
}]
bridge = TMCL_Bridge(host, modules)
logger.info("Interfaces initialized.")

while (not (bridge.process())):
    pass
Created on 14.10.2020

@author: LK
'''

from PyTrinamicMicro.connections.tmcl_host_interface import tmcl_host_interface
from PyTrinamicMicro.platforms.motionpy2.connections.rs485_tmcl_interface import rs485_tmcl_interface
from PyTrinamicMicro.platforms.motionpy2.connections.uart_tmcl_interface import uart_tmcl_interface
from PyTrinamicMicro.TMCL_Bridge import TMCL_Bridge
import logging

# Prepare Logger
logger = logging.getLogger(__name__)
logger.info("TMCL Bridge from UART to RS485")

logger.info("Initializing interfaces ...")
host = uart_tmcl_interface()
module = rs485_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.")
Пример #3
0
@author: LK
'''

from PyTrinamicMicro import PyTrinamicMicro
from PyTrinamicMicro.connections.tmcl_host_interface import tmcl_host_interface
from PyTrinamicMicro.platforms.motionpy2.connections.uart_tmcl_interface import uart_tmcl_interface
from PyTrinamicMicro.platforms.motionpy2.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 UART")

logger.info("Initializing interfaces ...")
host = usb_vcp_tmcl_interface()
module = uart_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.")
Пример #4
0
# Constants
MODULE_ADDRESS = 1
HOST_ADDRESS = 2
MODULE_ID_STRING = "0960"
VERSION_STRING = MODULE_ID_STRING + "V100"
BUILD_VERSION = 0

# Prepare Logger
logger = logging.getLogger(__name__)
logger.info("TMCL Slave on UART interface")

# Main program

logger.info("Initializing interface ...")
con = uart_tmcl_interface()
slave = TMCL_Slave_Main(MODULE_ADDRESS, HOST_ADDRESS, VERSION_STRING, BUILD_VERSION)
logger.info("Interface initialized.")

while(not(slave.status.stop)):
    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 ...")
con.close()