How Can I Close the remote LnrActrFirgelliNXT port?

This is where you talk about the EV3 software itself, installation issues, and programming talk.

Moderators: roger, gloomyandy, skoehler

SaYa
New User
Posts: 5
Joined: Thu May 11, 2017 4:32 pm

How Can I Close the remote LnrActrFirgelliNXT port?

Postby SaYa » Fri Jun 02, 2017 7:58 pm

I want to control the firgelli linear actuator to remote.

I know that I can use method createRegulatedMotor() when control the motor to remote.
But I want to use the method move in LnrActrFirgelliNXT class.(Because it is more smooth than use regulatedMotor.rotate()).

So I get Port from remoteEV3, and instance LnrActrFirgelliNXT with the port, and use move method.
But it cause the problem about opening/closing port.
So I want to close the port when the codes end.

I don't know how to close the port that I got with getPort() method.
Is there good solution about this problem?

I use 0.9.1-beta and the Linear actuator is made by Firgelli
here's my short code:

Code: Select all

 public static void main(String args[]){
        try {
            RemoteEV3 remoteEv3 = new RemoteEV3(BrickFinder.find("Brick1")[0].getIPAddress());
            Port A = remoteEv3.getPort("A");
            LnrActrFirgelliNXT firgelliNXT = new LnrActrFirgelliNXT(A);
            firgelliNXT.move(50,false);
            //TODO: close the port A.
        } catch (RemoteException e) {
            e.printStackTrace();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (NotBoundException e) {
            e.printStackTrace();
        }
    }

User avatar
gloomyandy
leJOS Team Member
Posts: 5867
Joined: Fri Sep 28, 2007 2:06 pm
Location: UK

Re: How Can I Close the remote LnrActrFirgelliNXT port?

Postby gloomyandy » Sat Jun 03, 2017 6:40 am

Instead of passing the port into the the actuator constructor, create and unregulated motor using it and pass this into the constructor, when your program is ready to exit you can then close the unregulated motor which in turn will close the port.
leJOS news https://lejosnews.wordpress.com/

SaYa
New User
Posts: 5
Joined: Thu May 11, 2017 4:32 pm

Re: How Can I Close the remote LnrActrFirgelliNXT port?

Postby SaYa » Sat Jun 03, 2017 7:43 am

Oh It work! Thank you very much!!! :D :D :D :D


Return to “EV3 Software”

Who is online

Users browsing this forum: No registered users and 5 guests