sebleedelisle / ofxLaser

An openFrameworks addon for controlling multiple lasers.
Mozilla Public License 2.0
258 stars 32 forks source link

SendRawPoints: Null pointer on default zone #26

Closed adminfriso closed 3 years ago

adminfriso commented 3 years ago

Hi Seb, after the update the zone has been added or is used otherwise than before.

https://github.com/sebleedelisle/ofxLaser/blob/ee014e8a0fca3ae55801eab249ef3b8821cf1e46/src/core/ofxLaserManagerBase.h#L75

if you take the combination set laser 0 -> zone 0 laser 1 -> zone 1 ...

and then try to run laserManager->sendRawPoints(dataVector, 0); all goes good, (default zone 0) laserManager->sendRawPoints(dataVector, 1); null pointer (screenshot) because it cannot be linked back correctly to the zone.

Screenshot 2021-06-22 at 15 01 09

suggested fix, remove the defaults to laser and zone.

void sendRawPoints(const std::vector<ofxLaser::Point>& points, int lasernum, int zonenum);

or change the sendRawPoints function to not explicitly use the zoneNum.

What are your thoughts on this?

c++ is not my strong language, but I could try to make a pr. What do you prefer?

sebleedelisle commented 3 years ago

Hey Friso, sorry you're still having trouble with this, honestly the sendRawPoints system is rarely used, it's kinda specialist. But I'm more than happy to work with you to get it sorted. I can't remember why I'm sending a zone to this method, let me look into it and I'll get back to you.

Seb

On Tue, 22 Jun 2021 at 14:45, Friso Modderman @.***> wrote:

Hi Seb, after the update the zone has been added or is used otherwise than before.

https://github.com/sebleedelisle/ofxLaser/blob/ee014e8a0fca3ae55801eab249ef3b8821cf1e46/src/core/ofxLaserManagerBase.h#L75

if you take the combination set laser 0 -> zone 0 laser 1 -> zone 1 ...

and then try to run laserManager->sendRawPoints(dataVector, 0); all goes good, (default zone 0) laserManager->sendRawPoints(dataVector, 1); null pointer (screenshot) because it cannot be linked back correctly to the zone. [image: Screenshot 2021-06-22 at 15 01 09] https://user-images.githubusercontent.com/23073031/122935161-676e1e80-d370-11eb-9c3d-b035075e4fba.png

suggested fix, remove the defaults to laser and zone.

void sendRawPoints(const std::vector& points, int lasernum = 0, int zonenum = 0);

or change the sendRawPoints function to not explicitly use the zoneNum.

What are your thoughts on this?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sebleedelisle/ofxLaser/issues/26, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA3CESDJNYVK4IXGRFJBH3TUCHZBANCNFSM47DXGCYA .

adminfriso commented 3 years ago

to be clear, I got it fixed for the project with Gijs (adding the zone to the method), but I thought it is good practice to tackle this before someone else also encounters it :)

Laser::sendRawPoints (ofxLaserLaser.cpp:529) uses getLaserZoneForZone (ofxLaserLaser.cpp:238) wich returns a nullpointer if the zone is not found.

Maybe instead of defaulting to nullpointer it is better to find the first available zone as fallback if no zone is matched in the loop above?

if then still not found: nullpointer, however, I do not know how to catch that in the sendRawPoints with all the masking thats going on...

sebleedelisle commented 3 years ago

Thanks so much for your help in identifying this issue, which I have now fixed. Now if you do not send a valid zone / projector to the sendRawPoints method it does nothing but output an error to the console.

I've tested it here but please do make sure it also works at your end. Thanks again!

adminfriso commented 3 years ago

Works like a charm!