-
Notifications
You must be signed in to change notification settings - Fork 221
SPI Plugin - TI TLC5971 support #1399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
peternewman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial review comments
plugins/spi/SPIOutput.cpp
Outdated
| // calculate DMX-start-address | ||
| const unsigned int first_slot = m_start_address - 1; // 0 offset | ||
|
|
||
| // calculate how much channels for full devices are available in dmx_buffer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SPaG: How many
|
|
||
| personalities.insert(personalities.begin() + PERS_TLC5971_INDIVIDUAL - 1, | ||
| Personality(m_pixel_count * TLC5971_SLOTS_PER_DEVICE, | ||
| "TLC5971 Individual Control (16bit per channel)")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably ideally want both 8 and 16bit individual and combined options eventually, but feel free to fix the underlying issues first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes - that is the plan when the rest works :-)
for the combined options there are more then one way to solve it...
- repeat/copy one set of driver channels (24ch) to all others
- repeat/copy the first 3 LED values (3 or 6 ch for 8 or 16bit modes) to all other positions
what do you think does make more sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it's a 4 channel RGB driver right, with global dimmer or similar over each RGB group? You could also use it as 3 channel RGBA drivers (although the global dimmer wouldn't align).
I suspect the latter option is likely to be a better fit for most people, but it's kind of hard to tell.
The main solution would be to implement http://rdm.openlighting.org/pid/display?manufacturer=31344&pid=32773 and then personalities can be independent of driver type and just offer a range of sensible ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes - its meant as 4xRGB - i think its not really global dimmer- is more a correction value per color group... (but it is a long time since i actually read the datasheet / wrote this code... - eventually there is both.. a correction and a color-group dimming)
as fare as i know all libraries (i have found) does not let you control any of the 'advanced' features..
for the PIXEL_TYPE thing i think that is handled in #871
do you mean it makes more sens i try and do this first? (iam currently unaware of how much work / where to start for this - but i can read on this...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think #871 should be masses of work @s-light , it should essentially be just tracking another variable and then using both to work out what function to run, rather than just personality. We probably also need to double check the RDM spec, but I think in theory every fixture should offer all personality sets, but perhaps just NAck the irrelevant ones (like a 24 channel clone on a normal RGB WS2801 or whatever). I suspect it broadly makes more sense to do it first, although I guess the bulk of the code to write is in the functions that actually process the DMX, so perhaps it doesn't make that much difference overall.
We should probably try and add the PIXEL_TYPE PIDs to the web UI, which will be interesting as the first manufacturer specific ones, but I can probably handle that bit. As well as that stuff needing to go in the config file.
plugins/spi/SPIOutput.cpp
Outdated
| // Device .. | ||
| // Device 2 | ||
| // Device 1 | ||
| // short brake of 8x period of clock (666ns .. 2.74ms) to generate latchpulse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SPaG break
| const unsigned int first_slot = m_start_address - 1; // 0 offset | ||
|
|
||
| // calculate how much channels for full devices are available in dmx_buffer | ||
| uint16_t devices_in_buffer = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be a uint8_t, or at least the value will always be < 255, or does it need to be a uint16_t as that's what buffer.Size() returns?
plugins/spi/SPIOutput.cpp
Outdated
| return; | ||
| } | ||
|
|
||
| // rename m_pxiel_count for easier understanding. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SPaG pixel
| PACK( | ||
| struct TLC5971_packet_config_fields_t{ | ||
| // Write Command (6Bit) | ||
| uint8_t WRCMD : 6; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay I've learnt some new syntax here. 😄
plugins/spi/SPIOutput.h
Outdated
|
|
||
| union TLC5971_packet_gsdata_t { | ||
| uint8_t bytes[24]; | ||
| // the uint16_t will not work everywhere because of endianess problems.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SPaG: endianness
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think some use of our Host to Network code should fix that issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will have a look at this..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Can you give us some working and broken configurations to compare please? |
|
thanks for your feedback! i test some configurations for comparison this evening and write up what i find. |
|
Here my tests / configurations: i only changed things in ola-spi.conf TLDR resultAs far as i can tell its related to the pixel-count value only.
(more than 21 is not possible because of the universe limit: 21*24=504) so much for tonight. i think i try to read through the code tomorrow once more and hope i find something that looks wired to me... details(i wrote it while testing.. to get it documented) 1. try the config as is - crash2. enable only 1 port with pixel-count 20 - works(only posting here what i have changed / is relevant..) 3. changing pixel-count to 21 - works4. change pixel-count to 1 - crasheserror message is 6. changing pixel-count to 20 and port count to 2 - works7. changing all pixel-count to 20 and port count to 12 - does not crasherror 8. changing all pixel-count to 20 and port count to
|
| pixel-count | error message |
|---|---|
| 3 | Speicherzugriffsfehler |
| 4 | *** Error in '/usr/local/bin/olad': malloc(): smallbin double linked list corrupted: 0x00094f70 *** Abgebrochen |
| 5 | *** Error in '/usr/local/bin/olad': malloc(): smallbin double linked list corrupted: 0x000851f8 *** Abgebrochen |
| 6 | *** Error in '/usr/local/bin/olad': malloc(): smallbin double linked list corrupted: 0x0008a738 *** Abgebrochen |
| 7 | *** Error in '/usr/local/bin/olad': malloc(): smallbin double linked list corrupted: 0x0009db50 *** Abgebrochen |
| 8 | worked for a short moment *** Error in '/usr/local/bin/olad': corrupted double-linked list: 0x00051160 *** Abgebrochen |
11. pixel-count 9 - works - kind of
works as long as its running - at the moment i hit Ctrl+C for exit i get
*** Error in '/usr/local/bin/olad': double free or corruption (!prev): 0x0009af60 ***
Abgebrochen
12. pixel-count 10 - works - kind of
similar to 9 - but at one occurrence i got an Segmentation fault and after this had to kill it manually...
olad/AvahiDiscoveryAgent.cpp:236: State for OLA Server._http._tcp,_ola, group 0xead00 changed to AVAHI_ENTRY_GROUP_ESTABLISHED
**^C**common/thread/SignalThread.cpp:115: Received signal: Interrupt
common/http/HTTPServer.cpp:537: Notifying HTTP server thread to stop
common/http/HTTPServer.cpp:539: Waiting for HTTP server thread to exit
common/http/HTTPServer.cpp:541: HTTP server thread exited
Received Segmentation fault
Getötet
13. pixel-count 11..19
| pixel-count | error message |
|---|---|
| 11 | *** Error in '/usr/local/bin/olad': corrupted double-linked list: 0x000ecdf8 *** Abgebrochen |
| 12 | worked for a moment *** Error in '/usr/local/bin/olad': corrupted double-linked list: 0x000a5280 *** Abgebrochen |
| 13 | *** Error in '/usr/local/bin/olad': corrupted double-linked list: 0x000a5280 *** Abgebrochen |
| 14 | worked kind of - like 9 |
| 15 | *** Error in '/usr/local/bin/olad': malloc(): smallbin double linked list corrupted: 0x0009ef28 *** Abgebrochen |
| 16 | crash like 10 - but had to kill it every time i tried |
| 17 | crash like 16 |
| 18 | crash like 16 |
| 19 | *** Error in '/usr/local/bin/olad': malloc(): memory corruption: 0x0008ae48 *** Abgebrochen |
|
Possibly relevant: I'd look at what you checkout from the SPI buffer, and how you access that afterwards. On a different note, if you update your branch compared to master, the Travis build should start working again. |
peternewman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few random thoughts on what might be breaking it.
| // should return 28byte = 224bit | ||
|
|
||
| // copy data to output buffer | ||
| // memcpy(output + spi_offset, device_data.bytes, sizeof(TLC5971_packet_t)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the memcpy not work? Why not, that ought to be quicker and safer.
| } // for devices_in_buffer end | ||
|
|
||
| // write output back | ||
| m_backend->Commit(m_output_number); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Low tech debug, add a log line before this, is it this causing the issue, or the code above.
this pull request adds support for the TI TLC5971 12Ch 16Bit LED-Driver Chips in the SPI-Plugin.
its basically working -
as fare as i have seen if a configuration works it will on every start.
but sometimes / some configurations leads to random
malloc(): memory corruptionandReceived Segmentation faultcrashes.That is not good 🪲
currently i think it has to do with amount of pixels/ports in use - but have no evident for this yet.
iam currently out of ideas how to start tracking down the course of this -
and hope one of you can give me a idea how to start debugging this. -
it definite has to do somehow with my code... and only shows if i use the plugin with the new pixel type.