bachmann-m200 / baem200

Other
4 stars 6 forks source link

Connect with QSOAP protocol #42

Open AnnaShcherenko opened 3 months ago

AnnaShcherenko commented 3 months ago

How is it possible to connect with QSOAP protocol without port number? There is no port parameter among connect method attributes. I tried to use M1Controller.setUintParam('M1C_QSOAP_PORT', port_number), but it doesn't work as well.

Kylja commented 1 week ago

As a default port 80 is used.

This can be changed by using the Target parameter key "M1C_QSOAP_PORT"

lets presume mh is a M1Controller instance, to set a different port number:

mh.setUintParam('M1C_QSOAP_PORT', xx)

where xx is your port number

Of course this has to be done before connection establishment

Kylja commented 1 week ago

Aha spoke to soon indeed this does not work.

The Q soap port number can only be set if the Target is created and before connecting. But the Target is created in the connect function and right after that the connection is establised. So when executing mh.setUintParam('M1C_QSOAP_PORT', xx) before the connection is made results in a failure (because the Traget dows not exists. Executing mh.setUintParam('M1C_QSOAP_PORT', xx) after connection establisment functions fine but is useless because then the connection is already establised on the default port 80

AnnaShcherenko commented 1 week ago

Hello Kylija, thank you for your help. I was able to solve the issue only when I create instance of PyCom class: self._pycom = PyCom() and then directly use functions from dll library: self.target_handle = self._pycom.TARGET_Create(self.ip_address.encode('utf-8'), 1, 1000) self._pycom.TARGET_SetUintParam(self.target_handle, 0x2, PORT) ret = self._pycom.TARGET_Connect(self.target_handle, self.user_name.encode('utf-8'), self.password.encode('utf-8'), "".encode('utf-8')) if ret != 0: self._pycom.TARGET_Dispose(self.target_handle)

Kylja commented 1 week ago

Yes this is fine for a workaround but we have to change this, probably by creating the Target in the M1controller init.

AnnaShcherenko commented 1 week ago

It will be helpful, thank you.