bschwind / ir-slinger

A small C library for sending infrared packets on the Raspberry Pi
The Unlicense
99 stars 30 forks source link

Problem with large codes #10

Closed ffleandro closed 7 years ago

ffleandro commented 7 years ago

As mentioned in the issue #9 , I've ported the code to use the pigpio daemon instead of the C standalone code wrapped in Python.

I'm using pyslinger and getting the following error with codes larger than 14 bytes.

Code generating error (14 bytes total): "1100000101100000000000000100010000000000000000000000000000000000000000000000000000000000000000000000000001000100"

Code successfully executed (13 bytes total): "11000001011000000000000001000100000000000000000000000000000000000000000000000000000000000000000001000100" Error log:

Processing IR code: 1100000101100000000000000100010000000000000000000000000000000000000000000000000000000000000000000000000001000100
Sending AGC burst
message handler error
Traceback (most recent call last):
 (...)
  File "/home/fhome/fresh-home-server/irslinger/pyslinger.py", line 240, in send_code
    pulses = self.gpio.wave_add_generic(self.protocol.wave_generator.pulses)
  File "/usr/local/pyenv/versions/fhserver/lib/python3.5/site-packages/pigpio.py", line 2115, in wave_add_generic
    self.sl, _PI_CMD_WVAG, 0, 0, len(pulses)*12, extents))
  File "/usr/local/pyenv/versions/fhserver/lib/python3.5/site-packages/pigpio.py", line 1001, in _pigpio_command_ext
    dummy, res = struct.unpack('12sI', sl.s.recv(16))
struct.error: unpack requires a bytes object of length 16

I will try to use the original pyslinger and also the C library code and report my results. Can someone also do this test to compare results?

ffleandro commented 7 years ago

I tried the original pyslinger code and it works fine, even with larger codes. So I guess there is some kind of limitation in the comunication packet size between pigpio python client and pigpiod process.

I improved the code to break the wave generation when size gets too big by making multiple calls to pigpio.add_wave_generic() and everything works fine. I'll try testing tomorrow with sending commands to a real device.

If someone needs this code let me know so I can make a pull request. Closing this issue since the problem was in my port and not the original code.