Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

get serial number from Visionary T-Mini #2

Open
maurizioscolasipi opened this issue Mar 18, 2024 · 5 comments
Open

get serial number from Visionary T-Mini #2

maurizioscolasipi opened this issue Mar 18, 2024 · 5 comments

Comments

@maurizioscolasipi
Copy link

Prerequisites

Put an X between the brackets on this line if you have done all of the following:

  • [ X] Checked that your issue isn't already filed

Current Behavior:

Expected Behavior:

Steps to Reproduce

Versions/Environment

Additional Information

@maurizioscolasipi
Copy link
Author

Current Behaviour:
cola command read variable: return error 32767

Expected Behaviour:
cola command read variable: return variable value

Steps to reproduce:
language C++
connect camera
execute this code:
std::string SickVTM::getSerialNumber()
{
using namespace visionary;
CoLaCommand getSerialNumber = CoLaParameterWriter(CoLaCommandType::READ_VARIABLE, "SerialNumber").build();
CoLaCommand serialNumberResponse = visionaryControl.sendCommand(getSerialNumber);
std::string sn = "";
if (serialNumberResponse.getError() == CoLaError::OK)
sn = CoLaParameterReader(serialNumberResponse).readFlexString();
return sn;
}

Versions:
Visual Studio 2022

Environment:
Windows 11

Additional information:
connect is working correctly
get intensity image works correctly
get depth map works correctly

@xfealal
Copy link
Collaborator

xfealal commented Apr 11, 2024

Hello @maurizioscolasipi,
we aren't able to reproduce your error. The method you're using to get the SerialNumber looks fine.
Can you provide us the exact terminal output?

@maurizioscolasipi
Copy link
Author

Hello everybody,
this morning I solved but I can't uderstand a strange behaviour of Visual Studio.

If I execute:

std::string sn = "";
CoLaCommand getSerialNumber = CoLaParameterWriter(CoLaCommandType::READ_VARIABLE, "SerialNumber").build();
CoLaCommand serialNumberResponse = visionaryControl.sendCommand(getSerialNumber);
if (serialNumberResponse.getError() == CoLaError::OK)
sn = CoLaParameterReader(serialNumberResponse).readFlexString();

and I set a breakpoint I see that the program counter jump the line
sn = CoLaParameterReader(serialNumberResponse).readFlexString();
and I think: I have and error; so I change the code in this way:

CoLaCommand getSerialNumber = CoLaParameterWriter(CoLaCommandType::READ_VARIABLE, "SerialNumber").build();
CoLaCommand serialNumberResponse = visionaryControl.sendCommand(getSerialNumber);
visionary::CoLaError::Enum outcome = serialNumberResponse.getError();
printf("outcome: %d\n", outcome);
if (outcome == CoLaError::OK)
sn = CoLaParameterReader(serialNumberResponse).readFlexString();

and it works! I think the printf instruction forces Visual Studio to evaluate correctly serialNumberResponse.getError() but it's a very strange behaviour.

Now I modified again the code:

CoLaCommand getSerialNumber = CoLaParameterWriter(CoLaCommandType::READ_VARIABLE, "SerialNumber").build();
CoLaCommand serialNumberResponse = visionaryControl.sendCommand(getSerialNumber);
//visionary::CoLaError::Enum outcome = serialNumberResponse.getError();
//printf("outcome: %d\n", outcome);
if (serialNumberResponse.getError() == CoLaError::OK)
sn = CoLaParameterReader(serialNumberResponse).readFlexString();

and it works!

Can anybody explain to me this strange behaviour?
Thanks

@xfealal
Copy link
Collaborator

xfealal commented May 3, 2024

Hello @maurizioscolasipi, We’re glad that you’ve been able to solve your issue. Unfortunately, we cannot explain the undefined behavior you’re experiencing with your code. As a hint, you can check if you’re using code optimization in the Visual Studio debugger. If it’s enabled, turn it off and run your code again. Hope this helps.

@maurizioscolasipi
Copy link
Author

Hello xfealal,
code optimization is already disabled (/Od).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants