Disconnect an Reconnect to CoppeliaSim B0RemoteApi

Typically: "How do I... ", "How can I... " questions
Post Reply
Florent
Posts: 14
Joined: 20 Mar 2020, 23:22

Disconnect an Reconnect to CoppeliaSim B0RemoteApi

Post by Florent »

Hello,

I am using C++ B0 Remote Api on Windows 10 and CoppeliaSim 4.1.0. I am able to connect to CoppeliaSim by using:

Code: Select all

b0RemoteApi* client = new b0RemoteApi("MyClient", "b0RemoteApi");
Then I can do different stuff, but then I would like to "disconnect" from the server and I use:

Code: Select all

client->b0RemoteApi::~b0RemoteApi();
Afterwards I would like to connect again to the server but I get the error message:
Initialization failed: already initialized
I am doing this because I am implementing a GUI where I connect to different servers (modbus, OPCUA, b0 etc...) and I need to disconnect from them too.

I there a better way to disconnect from the server? Can I reconnect to the server after disconnecting?

Thanks for your help,

Best regards,

coppelia
Site Admin
Posts: 10375
Joined: 14 Dec 2012, 00:25

Re: Disconnect an Reconnect to CoppeliaSim B0RemoteApi

Post by coppelia »

Hello,

that is strange. Can you confirm that your b0RemoteApi.cpp contains following in the constructor?

Code: Select all

    if (b0_is_initialized()==0)
    {
        int arg1=1;
        const char* arg2="b0C";
        b0_init(&arg1,(char**)&arg2);
    }
If yes, does that condition pass?

Cheers

Florent
Posts: 14
Joined: 20 Mar 2020, 23:22

Re: Disconnect an Reconnect to CoppeliaSim B0RemoteApi

Post by Florent »

Hello,

No the lines of code you've written were note present, only this:

Code: Select all

int arg1=1;
const char* arg2="b0C";
b0_init(&arg1,(char**)&arg2);
I changed with the ones you wrote and it works fine now. Thank you,

Best regards,

coppelia
Site Admin
Posts: 10375
Joined: 14 Dec 2012, 00:25

Re: Disconnect an Reconnect to CoppeliaSim B0RemoteApi

Post by coppelia »

Could it be that you used a different version of the B0-based remote API than the one that was shipped with CoppeliaSim V4.1.0?

Cheers

Florent
Posts: 14
Joined: 20 Mar 2020, 23:22

Re: Disconnect an Reconnect to CoppeliaSim B0RemoteApi

Post by Florent »

It could be, because I work on this project for more than one year now and even if i installed Coppelia sim 4.1.0 in between, I don't know if i changed the binding to the "new" b0RemoteApi.cpp and b0RemoteApi.h

Post Reply