Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Clearing port
#1
Hello—

I am defining a port in a procedure:

R=RotaryEncoderModule('/dev/cu.usbmodem2812891');

When I exit and restart the protocol I am met with:

Error using ArCOMObject_Bpod (line 129)

Error: Unable to connect to port /dev/cu.usbmodem2812891. The port may be in use by another application.

The command clear R does not remedy the situation and my only option appears to be to restart Matlab.

Any suggestions?

Thank you,

Randy
Reply
#2
Hi Randy

When you create rotary encoder object R, one of the object's fields is SerialPort, a wrapper for a USB serial port leased to object R by your operating system. When you clear variable R from your workspace (or if R was created in a function, when the function ends), the R object's destructor method is called, relinquishing control of the port.

In your case, the fix is to run 

clear R

at the end of your protocol.

-Josh
Reply
#3
(01-25-2018, 07:43 PM)Josh Wrote: Hi Randy

When you create rotary encoder object R, one of the object's fields is SerialPort, a wrapper for a USB serial port leased to object R by your operating system. When you clear variable R from your workspace (or if R was created in a function, when the function ends), the R object's destructor method is called, relinquishing control of the port.

In your case, the fix is to run 

clear R

at the end of your protocol.

-Josh

Hi Josh—

Rookie mistake on my part.  The object 'R' was being defined as a global variable, so it was not being cleared when the function ended. 

Thanks for your help,

Randy
Reply


Forum Jump: