-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Identify Module Model using Connection Manager #105
Comments
Hi @JeffPS13, from pytrinamic.tmcl import TMCLCommand
...
get_fw_result = self.my_interface.send(TMCLCommand.GET_FIRMWARE_VERSION, 1, 0, 0, module_id=1) # use module_id=2 for the other interface
module_code = get_fw_result.value >> 16
print(module_code) I did not test this code, but this should be it. |
Thanks for the quick response. When I run this I get: AttributeError: 'ConnectionManager' object has no attribute 'send' |
Did you remove the " self.my_interface = ConnectionManager("--interface usb_tmcl --port COM11") vs self.my_interface = ConnectionManager("--interface usb_tmcl --port COM11").connect() |
Still getting this error: AttributeError: 'ConnectionManager' object has no attribute 'send' Here's my code:
|
This should do it: from pytrinamic.connections import ConnectionManager
from pytrinamic.tmcl import TMCLCommand
my_interface = ConnectionManager("--interface usb_tmcl --port COM11").connect()
get_fw_result = my_interface.send(TMCLCommand.GET_FIRMWARE_VERSION, 1, 0, 0, module_id=1)
module_code = get_fw_result.value >> 16
print(module_code)
my_interface.close() # properly close the COM-port Note, that BTW: To not forget the close() you better use the with statement from pytrinamic.connections import ConnectionManager
from pytrinamic.tmcl import TMCLCommand
connection_manager = ConnectionManager("--interface usb_tmcl --port COM11")
with connection_manager.connect() as my_interface:
get_fw_result = my_interface.send(TMCLCommand.GET_FIRMWARE_VERSION, 1, 0, 0, module_id=1)
module_code = get_fw_result.value >> 16
print(module_code)
# my_interface.close() is automatically called when exiting the scope of the with context |
Thanks, this works and returns the model numbers of the modules connected to each COM-port. Regarding using "with" and or close(), I'm a bit confused. My application is constantly sending and receiving with the modules, what is the benefit of closing and opening the interface multiple times? I close the interface when the application closes. If I'm not using best practices please advise. Thank you very much, |
There is no need to close and reopen multiple times, just make sure to do the close if the application closes. |
Hello,
I have two TMCL modules connected via usb and I connect to them using the code below. However, would like to programmatically identify the module model that is connected to each COM port. I've used port_list in connection_manager.py to return the COM ports with TMCL modules attached but I don't see a means of returning the module model.
Thanks,
Jeff
The text was updated successfully, but these errors were encountered: