Skip to content

Conversation

@Keeper-of-the-Keys
Copy link

The support is not 100% according to the standard, it for instance does not check if after the minimum wait duration a full packet was actually received and if not waits longer.
This should of course only be a problem for devices that for some reason don't manage to send an RDM packet within normal/optimal timings.

I figure that adding that logic/better timings should be part of a separate later PR.

E.S. Rosenberg a.k.a. Keeper of the Keys added 24 commits December 3, 2018 01:22
This will probably replace Write(DmxBuffer) in the future and maybe should return bool.
…or logic to prevent memory leaks (I hope).
…rewrite/undo a lot of my changes but figure I should maintain stuff just in case.
…or ftdidmx, code still very ugly and hacky and olad doesn't shut down properly.
It still doesn't work and some behaviors are plain wrong (the callbacks being called when stuff can't get to the line)
Sadly my second FTDI interface is broken so I can't currently check if RDM packets are actually hitting the line or not.

Also still leaves olad that doesn't shutdown without kill -9.
Added the DiscoveryAgent and inheritance from DiscoverableRDMControllerInterface
At this point only UnMuteAll gets called, after its' callback is fired no further RDM packets are sent.
Also I'm pretty sure I may be leaking some memory.
Added some more debug output for when an operation is pending/
…more debug output.

Works now, but reply is not being read I really need to get another FTDI interface or some other way to monitor the line :/
Also shutdown works again (which may be due to next commit)
… switching messing up the reading of the reply.

Still no luck, will need to wait for new FTDI board to read the line.
1. Clear packetbuffer before use.
2. Fix logic of callbacks (else was to wrong if())
3. Fix packet reconstruction for non-DUB replies:
 the MAB is recognized as another byte by the FTDI so it reads 1 byte more then the actual packet
 so we hand of starting 1 byte later and 1 byte less total.
It runs them, the pending request should be destroyed by the core that generated it which is why it can be set to null.
Old scheduling logic commented out, will be removed in next commit.
Copy link
Member

@peternewman peternewman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few initial notes to get you started...

@peternewman
Copy link
Member

Travis lint errors will need fixing too:
https://travis-ci.org/OpenLightingProject/ola/jobs/498695471

@peternewman
Copy link
Member

And this compiler error:

libtool: compile:  ccache g++-8 -DHAVE_CONFIG_H -I. -I../.. -Wno-deprecated-declarations -I../../include -I./include -Wall -Wformat -W -fvisibility-inlines-hidden -pthread -Werror -Wno-error=deprecated-declarations -g -O2 -std=gnu++11 -pthread -MT plugins/ftdidmx/FtdiDmxThread.lo -MD -MP -MF plugins/ftdidmx/.deps/FtdiDmxThread.Tpo -c ../../plugins/ftdidmx/FtdiDmxThread.cpp -o plugins/ftdidmx/FtdiDmxThread.o >/dev/null 2>&1
../../plugins/ftdidmx/FtdiWidget.cpp: In member function ‘bool ola::plugin::ftdidmx::FtdiInterface::Write(ola::io::ByteString*)’:
../../plugins/ftdidmx/FtdiWidget.cpp:373:61: error: invalid conversion from ‘const unsigned char*’ to ‘unsigned char*’ [-fpermissive]
   int bytesWritten = ftdi_write_data(&m_handle, packet->data(), packet->size());
                                                 ~~~~~~~~~~~~^~
In file included from ../../plugins/ftdidmx/FtdiWidget.cpp:42:
/usr/include/ftdi.h:406:67: note:   initializing argument 2 of ‘int ftdi_write_data(ftdi_context*, unsigned char*, int)’
     int ftdi_write_data(struct ftdi_context *ftdi, unsigned char *buf, int size);
                                                    ~~~~~~~~~~~~~~~^~~

@peternewman
Copy link
Member

It works though!!! I've just plugged in an FTDI RS485 lead and done some discovery and identify! 🎆 🍾 💯 👍

@peternewman
Copy link
Member

And this compiler error:

libtool: compile:  ccache g++-8 -DHAVE_CONFIG_H -I. -I../.. -Wno-deprecated-declarations -I../../include -I./include -Wall -Wformat -W -fvisibility-inlines-hidden -pthread -Werror -Wno-error=deprecated-declarations -g -O2 -std=gnu++11 -pthread -MT plugins/ftdidmx/FtdiDmxThread.lo -MD -MP -MF plugins/ftdidmx/.deps/FtdiDmxThread.Tpo -c ../../plugins/ftdidmx/FtdiDmxThread.cpp -o plugins/ftdidmx/FtdiDmxThread.o >/dev/null 2>&1
../../plugins/ftdidmx/FtdiWidget.cpp: In member function ‘bool ola::plugin::ftdidmx::FtdiInterface::Write(ola::io::ByteString*)’:
../../plugins/ftdidmx/FtdiWidget.cpp:373:61: error: invalid conversion from ‘const unsigned char*’ to ‘unsigned char*’ [-fpermissive]
   int bytesWritten = ftdi_write_data(&m_handle, packet->data(), packet->size());
                                                 ~~~~~~~~~~~~^~
In file included from ../../plugins/ftdidmx/FtdiWidget.cpp:42:
/usr/include/ftdi.h:406:67: note:   initializing argument 2 of ‘int ftdi_write_data(ftdi_context*, unsigned char*, int)’
     int ftdi_write_data(struct ftdi_context *ftdi, unsigned char *buf, int size);
                                                    ~~~~~~~~~~~~~~~^~~

This fixes it, and works for me:
int bytesWritten = ftdi_write_data(&m_handle, const_cast<unsigned char*>(packet->data()), packet->size());

@peternewman
Copy link
Member

peternewman commented Feb 26, 2019

Also can you update the FTDI plugin's readme please, probably with a general note, and a list of known good, and known bad devices, where it works or doesn't (e.g. the likely biasing issue on the Enttec Open, although I never could find the circuit diagram the other day to confirm).

E.S. Rosenberg a.k.a. Keeper of the Keys added 21 commits July 28, 2019 18:16
…r seems more logical at hw level so moved there.

Thread level function still commented out in code will be removed later.
The thread does not seem to need to be echo aware, however once I do tests we'll know for sure.
… is ON.

Also fixed debug output targets to right targets.
TODO: Add echo detection to setup.
TODO: Convert Write(DmxBuffer) to use Write(ola::io::ByteString)
As mentioned on IRC it seems to me that this behavior is not desirable.
far causes crashes because Size() is too often 0 instead of within allowed range.
TODO: Update docs and run through valgrind.
Valgrind results suggests no leak in plugin, however there do seem to be leaks in RDM Core.
…null packets also with only 24 slots of data.
…d list into variable.

Also one spelling correction I missed.
Copy link
Member

@peternewman peternewman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some more comments

m_tv.tv_usec / ONE_THOUSAND);
}

int64_t BaseTimeVal::InMicroSeconds() const {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This returns exactly the same value as BaseTimeVal::AsInt(), any reason we need the second function?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is returning msec not usec...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess AsInt is too then; I've just double-checked and the code is identical in both, only the method name changes.

timespec req;
req.tv_sec = requested / USEC_IN_SECONDS;
req.tv_nsec = (requested % USEC_IN_SECONDS) * ONE_THOUSAND;
req.tv_sec = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this assigned and then reset?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect an error on my part, though I also have a suspicion that maybe I did not want this function to exceed 1s

bool StringToInt(const string &value,
unsigned int *output,
bool strict,
uint8_t base) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like the stuff in https://github.com/OpenLightingProject/ola/blob/master/common/utils/StringUtilsTest.cpp#L541-L564 for example.

So passing in something in base 36, and also validating that 123ABC converts to the same value as 123abc.

return false;
}

*output = static_cast<unsigned int>(l);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if we've returned false we shouldn't bother setting the value.

class FtdiDmxThread : public ola::thread::Thread {
enum {
HALF_SECOND_MS = 500,
ALMOST_SECOND_MS = 900,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise

@Keeper-of-the-Keys
Copy link
Author

@peternewman I may want to retry getting this in, I suspect it will be better to do a new PR against the current branch and maybe also smaller PRs (in as much as that is possible) that add differnent features, WDYT?

@CaptChrisD
Copy link

@Keeper-of-the-Keys I -- as well as others -- am also interested in getting this in. Any chance some effort could be put towards this.

@Keeper-of-the-Keys
Copy link
Author

@Keeper-of-the-Keys I -- as well as others -- am also interested in getting this in. Any chance some effort could be put towards this.

I tried picking it back up but it turns out I broke one of my FTDI boards, I don't really have budget at the moment to buy new boards and thus it got snowed under other projects that pay my bills at the moment.

Specifically this PR is too large to get merged IMHO and my plan was to start working on the different components and get them merged one by one but as said need working hardware to develop software.

That being said I do still hope to get to it...

@CaptChrisD
Copy link

@Keeper-of-the-Keys would you mind reaching out to me? chris at bigcove.io

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants