Programming a SerialPort on a Mac with M1 chip on Matlab2021b
Mostra commenti meno recenti
Hello! I am attempting to connect a serialport. I am using a Macbook Pro with an M1 chip with Matlab version 2021b. I am attempting to connect the Belkin Connect USB-C 4-in-1 Multiport Adapter, AVC006. What is important is that one of the usb ports of the Belkin adapter is connected to two pumps. The hope is that the script will program the pumps to deliver liquid at specific intervals and for specific amounts of time. The script has worked on a Lenovo with Matlab 2017b, but with the Lenovo the USB connected to the pumps was directly connected to the computer and not through an adapter. Unfortunately the adapter is necessary as the Mac only has 2 USB-C ports.
Here is the code currently being used:
s1=serialport('/dev/tty.usbserial-110',19200)
configureTerminator(s1, "CR", 13)
fopen(s1);
This is the error that currently appears:
Error using serialport (line 116)
Unable to connect to the serialport device at port '/dev/tty.usbserial-110'. Verify
that a device is connected to the port, the port is not in use, and all serialport
input arguments and parameter values are supported by the device.
See related documentation for troubleshooting steps.
Error in shake (line 69)
s1=serialport('/dev/tty.usbserial-110',19200)
Any help on trying to write this code correctly would be greatly appreciated! Thank you!
2 Commenti
Walter Roberson
il 17 Dic 2021
Note: when you use serialport() you do not use fopen() . The port opens itself, and there is no way to open and close the port except by creating or destroying the object.
configureTerminator(s1, "CR", 13)
When you use configureTerminator, you only need three parameters if your read terminator is different than your write terminator. But both "CR" and 13 convey the same value, so your terminators are the same.
Note: configuring the terminator is not the reason you are having problems. You are not getting that far.
Walter Roberson
il 17 Dic 2021
Be sure to check the permissions on the port to see if you are permitted to open it.
!ls -l /dev/tty.usbserial-110
Also, I have known Mac to change the name of a usbserial device if it gets plugged into a different port. I have also seen evidence that the -110 part of the name is normally derived from internal device identification, so I would expect it to stay constant as the device is plugged into a different port... but it is not always the same.
Risposte (0)
Categorie
Scopri di più su Serial and USB Communication in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!