Skip to content
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

512 bytes limit for png and gif on new 32x32 panel from Ali Express #50

Open
TomCat666 opened this issue Oct 10, 2024 · 31 comments
Open
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@TomCat666
Copy link

TomCat666 commented Oct 10, 2024

Hello

I have a problem with a new 32x32 panel I bought from AliExpress:

https://www.aliexpress.com/item/1005006130862334.html?spm=a2g0o.order_list.order_list_main.29.6c191802RhNszc

For some reason only png and gif files that are smaller than 512 bytes work on it. If I send bigger png's then I get black screen, if I send bigger gif animations then it goes directly to the default animations on the device. Don't know what to do but as soon as the file is bigger than 512 bytes I can't send anything. Clocks, countdowns, score panel, etc. all work fine.

Note: All animations from the iDotMatrix app and everything there works fine, so there is a problem somewhere else when sending data, I think.

Also I can import the same gif animations from photos to the iDotMatrix APP and it will display them perfectly, so definetly not a size problem on the device. But it is such a shitty APP ... I would love to be able to just use my rPI and send the gif's to the device in random order with a simple bash script.

@TomCat666
Copy link
Author

Note: tried chaning the png_chunks = self._splitIntoChunks(png_data, 4096) 4096 to 512 or 256 and I got the same result... no difference

@TomCat666
Copy link
Author

I did a build on Windows, just to see if there is something wrong with my rPi3 build and I get the same problem - as soon as the PNG/GIF is bigger than 512 bytes it doesn't want to upload. But on windows I get an actual error when using bigger files than 512:

11.10.2024 02:04:36 :: DEBUG :: idotmatrix.connectionManager :: sending message(s) to device
11.10.2024 02:04:36 :: ERROR :: idotmatrix.modules.image :: could not upload the unprocessed image: [WinError -2147024809] The parameter is incorrect

@TomCat666
Copy link
Author

More investigation... In the method _createPayloads as soon as the whole payload that is created extends 512 bytes I get the error.
Is there a possibility to get the info of the reverse engineering of how the payload is sent ? Was reverse engineering done on the code or on the actual BT data that was sent to the device?

@TomCat666
Copy link
Author

Found a github repository https://github.com/8none1/idotmatrix
It has a working implementation of GIF and image upload that works with ANY file size (even bigger than 4096) ...
so if anyone wants to bug fix this repository then check it out. I haven't had time to actually check it yet.

Won't be closing this issue until someone fixes it.

@derkalle4
Copy link
Owner

Hi @TomCat666 you're right. This still is an ongoing issue. However, I am still not able to work as much for this project as I wanted to. I'll mark your issue and will look into it :)

@derkalle4 derkalle4 self-assigned this Oct 19, 2024
@derkalle4 derkalle4 added bug Something isn't working good first issue Good for newcomers labels Oct 19, 2024
@ellensp
Copy link

ellensp commented Oct 25, 2024

only difference I can see from what https://github.com/8none1/idotmatrix generated is in the size field of the headers

field "total payload size inc headers over all chunks " for the example 18 animated gif (raw gif size is 5599 bytes 0x15df https://github.com/8none1/idotmatrix/blob/main/assets_test/downloads/NEWGIFS2/18.GIF)

eg chunk0 "ff 15 00 00" while this library uses "ef 15 00 00"

diff idotmatrix_controller.log python3-idotmatrix.log 
2c2
< 1010010000ff1500009c841fd505000d
---
> 1010010000ef1500009c841fd505000d
261c261
< ef05010002ff1500009c841fd505000d
---
> ef05010002ef1500009c841fd505000d

Here are the logs (formatted into 16 byte lines)
logs.zip

But I cant make either upload this 18.GIF

Ill re-enable bluetooth logging and see the app is doing (in a few days, if I get time)

@ellensp
Copy link

ellensp commented Oct 25, 2024

Typical. I upload the example 18.gif to my phone and sent it to the idotmatrix, and guess what it doesn't display via the app either!! (yes its 32x32 which matches my device)

@derkalle4
Copy link
Owner

@ellensp I have committed some updates to the idotmatrix-libary as well as bumping the library version in this repository. Simply run "create_venv.sh" again and check if it is working now. There is some upper timeout for GIFs. Maybe someone can figure this out. At least my bigger demo gifs with around 6 to 8kb are working now.

Please see also issue #32 which also is about gifs not working correctly.

@derkalle4
Copy link
Owner

Update: seems it still works unreliable. Worked even after reboot and now it isn't working properly anmore. Damn china stuff :D

@TomCat666
Copy link
Author

Doesn't seem to work at all here for GIF's bigger than 512 bytes still....
Yea, china stuff ... its cheap, but then you get this :)

I got the other library working nicely now though. The author added the reset (delete) command which I need to call every 20 or so gif uploads so the device is reset (only takes a fraction of a second). If I don't do that then it looses connection after a while (china stuff :) ). Now it is running non-stop 24/7 without any hiccups.

@derkalle4
Copy link
Owner

@TomCat666 okay, I will look into this again :) should be fixable. No idea currently what exactly the problem is though.

@ellensp
Copy link

ellensp commented Oct 30, 2024

can you provide a example or two that never works

@TomCat666
Copy link
Author

TomCat666 commented Nov 3, 2024

A few that never work here:
SoldierAll
boy
FoxWalk

@ellensp
Copy link

ellensp commented Nov 5, 2024

All 3 examples provided uploaded to my 32x32 iDotMatrix display without issues using the python3-idotmatrix-client

Ie the following commands all worked fine. (your address will be different)
python app.py --address 0E:81:B3:86:B3:54 --set-gif ~/Downloads/382560499-04c88252-44b6-4eaf-81cd-87e45f29e77a.gif
python app.py --address 0E:81:B3:86:B3:54 --set-gif ~/Downloads/382560492-8118ef99-57b4-4fe5-a92d-aa57a66bb59a.gif
python app.py --address 0E:81:B3:86:B3:54 --set-gif ~/Downloads/382560475-beb13043-9adc-4019-acb6-084852026e0f.gif

Make sure you updated the idotmatrix library to 0.0.7
Eg im using venv, a pip list on my machine

(venv) :~/Downloads/iDotMatrix/python3-idotmatrix-client$ pip list
Package                   Version
------------------------- -------
altgraph                  0.17.4
asyncio                   3.4.3
bleak                     0.22.3
cffi                      1.17.1
cryptography              43.0.3
dbus-fast                 2.24.3
idotmatrix                0.0.7            <-------------------------------- make sure yours says 0.0.7
packaging                 24.1
pillow                    11.0.0
pip                       24.0
pycparser                 2.22
pyinstaller               6.11.0
pyinstaller-hooks-contrib 2024.9
PyQt5                     5.15.11
PyQt5-Qt5                 5.15.15
PyQt5_sip                 12.15.0
setuptools                75.2.0

@TomCat666
Copy link
Author

Ahh, that was it. After updating it is working now. Thank you !

@creathinq
Copy link

Hi. gifs are working fine in 0.0.7, but I have a problem with PNGs. no matter what, only PNG I got working was demo_32.png - yellow duck. I tried upload.Processed and uploadUnprocessed. demo_16.png does come trhough to the display but only if sent Unprocessed, and it comes scrambled - image unusable, just trying to think of the reason for this behavior.

I did not get working any of my own PNGs, no matter how resized, resampled, stripped of alpha, etc, none worked. Filesize is no indicator too, as demo_16 is pretty smal and it still fails. Does anybody have any idea? my files:

-rw-r--r-- 1 pi pi 1.3K Jun 21  2019 ./images/10n.png
-rw-r--r-- 1 pi pi  734 Nov 19 23:39 ./images/10n_r.png
-rw-r--r-- 1 pi pi  259 Nov 19 23:19 ./images/demo_16.png
-rw-r--r-- 1 pi pi  430 Nov 19 23:19 ./images/demo_32.png
-rw-r--r-- 1 pi pi 1.4K Nov 19 23:19 ./images/demo_512.png
-rw-r--r-- 1 pi pi  520 Nov 19 23:19 ./images/demo_64.png

error is still the same:
ERROR :: idotmatrix.modules.image :: could not upload processed image: [org.bluez.Error.Failed] Failed to initiate write

@ellensp
Copy link

ellensp commented Nov 20, 2024

After patching the client to accept a command line that made sense

diff --git a/core/cmd.py b/core/cmd.py
index aad3381..0b1086d 100644
--- a/core/cmd.py
+++ b/core/cmd.py
@@ -520,15 +520,15 @@ class CMD:
             await image.setMode(
                 mode=1,
             )
-            if args.set_image:
+            if args.image:
                 if args.process_image:
                     await image.uploadProcessed(
-                        file_path=args.set_image,
+                        file_path=args.image,
                         pixel_size=int(args.process_image),
                     )
                 else:
                     await image.uploadUnprocessed(
-                        file_path=args.set_image,
+                        file_path=args.image,
                     )
 
     async def gif(self, args):

using python app.py --address 0E:81:B3:86:B3:54 --image ./images/demo_32.png

produces 439 bytes of data to send.

idotmatrix.modules.image :: data: bytearray(b'\xaf\x01\x00\x00\x00\xae\x01\x00\x00\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\x00\x00szz\xf4\x00\x00\x00\tpHYs\x00\x00\x0b\x13\x00\x00\x0b\x13\x01\x00\x9a\x9c\x18\x00\x00\x01`IDATX\xc3\xddWKj\xc30\x10\x9d1\xb1\xbd\xf3MB\x02\xa1\xc2\xd9v\xe3]\x16=\x81O\x18Jw>@\x891\xc4$\xf4&ZZ\x8b\xc9\xc6\tvj\xfd\x15\x15: 0h\xa4\xf7f4?\x03\xfc\xb1\xa0\xa5>\x85\xbe\xd3F\x99\x04gZ\xa5\xb4\xe8\xac\xeeMB\x82\xbbH\xe2sx\xb4v\xf6=\x12\xa5(\x04b\x06\xe1\xe2\x13L=\xe0\x8acL\xa0m2\xd8\xed\xb73pq4\x08\xca\x8f.\x08\x81_$\xd2\xa2\x83\xbe\xcea}\xd8<\x83Y\xe1x\xc7\xc0\xcf\xd7\xf5\xf1-\x8el\xea\x15\x9c\xac`Bm\x93\x91\xe0\x8c\x04g4F\xbbl\xbdLf$\xda&{9\xa0,+\x82\x90\x08R\x07v\xfb-\xb4M\x06.$\xd0\xf1\tf)\xe9\xd3\x0b\xd0\xc1\xf5A\x1b\x12\x1a\xb6]\xb4mH\xa6$\xd0\xc4\xca\xe7\x92\xbb\xb4\xaf(\xd5J\x12+S\x8b\\\xda\xb1\xe0\x0c\xd2\xa2#\xebJx>]\xa2\xe5\xf3\x12\x01,\xab!\x1a\x89\xc4\xc2\x95\xd2`\x1bk\x80\x93\'e1\x80e5\x90\xe0z\x12\xaa\x9a`"+\x1b\xe5%Ke\xe0\xe7\xd3\x05\xcaj\xd0f\x81.O\xe9\xfb\x13\x81\xbd\xbfYYe\nnZ\xad|:]\xd8Y\xa0\xafsY\xd7\xa3\xbe\xceU\xfb\xfe\xff\x05}\x9d?\xa6\x1e\x19\xc8\xfa\xb0Q\xee{\xb7\xe3\xfb\xfc\xa7\x03\xb1!a<\x15k\xceS\x8c\x18\xf8\x9fr\x03\x9a\x10\xb2\xad\xf3\x11\xa1\x0e\x00\x00\x00\x00IEND\xaeB`\x82') size: 439

using python app.py --address 0E:81:B3:86:B3:54 --image ./images/demo_16.png --process-image 32
This did resize correctly "resized img.size: (32, 32)"
but produced 2296 bytes of data to send. this is to much data for the bluetooth module.

idotmatrix.modules.image :: data: bytearray(b'\xf0\x08\x00\x00\x00\xef\x08\x00\x00\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\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3\xaf,\xc9\x16\xb9\x022\x8a\xa9\xe4\x1e$\xe1d[\x05S\\3\x02\xca\x035\x00z\x0f\xb0\x87\\\xcd\xf7\xa6\x97\xb9#\xd3J\xdd \x7f\xc06`\xaa\xeb(tN\xc5(\x13\xa5\xe2\x82yH\xaeq\x18\x85\x0b\x84\xd7\xc4\xc8\xfe\xf8&K\x8cR\xf2\xe2N\xf1\x0f%\xc3}\xa0_\xc8\xd3<\xfd\xb5\xfa\xe8\xbc\xd7\x1fj\x940P\xd9\xc7\x7fwB\xed=5\x12\x02\xae\x12\xc5h\x93=\x91\xc6\xe3I\x15\x8e\x96\xe5\xc6F\xb7&\x1a\xd55\x15\x15\xc6--U\x91\xe2\x84\xc4\xcaJ\x89\xb8.\x81\xc8\xf5\x9bE\xd8\x1c\x8d\xaa\xa0\xba\xda\x89\x94\x95\xdb\xb1\xab*\xadHu\x8d\xed\xba\xae\xaaq]jR\xef\xdc\xef\x04\xcf^Q\xe7}\x89@Q\xa5r\xbdA$\xc2\x12\xad\xf9\xb2,\xaa\xa4\xa5NKK\xad\x96\xb2\xa8\x12\xad\xd8\x93HP\xda\x98\xa0Tk\xf6T&lY:\'.\xb7\xcd\x89Ke\xc2\x16\xad\xf8\x12X"mmy\x0fL\xec\x82\xc26I\x91{Dd\xf3\xf3\x19\xc0c\xf9q,>\x01~\x91\xff_\r\xcc-\xd8\xff\x1cx=?B\xae)\xf5\x18\xc7\x15\xe3\xf5icKf\x8c\xdc\xcb\xb8\xa8\x80&\t\x9c\xcc\xffO"\xdf\x8a\x8d\xc10\xd0E\xee\x15]\xc8\xf3\x7f\np\xb9D\n\xec\xbc\x01\xbd\x10\xc2\x02=\x8cV8V\x8eU\xd6\x17\x82B\x82\xaf\xc0\x7f\x01\xa7\x8c\x9d4\xb4y\xda7\x00\x00\x00\x00IEND\xaeB`\x82') size: 2296

@TomCat666
Copy link
Author

TomCat666 commented Nov 20, 2024

Only using GIF's for now and after testing PNG's same problem here.

There are cheap 64x64 LED panels now available which seem to use the same protocol and app... anyone tried those yet?

Link to Ali express

@ellensp
Copy link

ellensp commented Nov 20, 2024

The library needs to transmit smaller blocks

in https://github.com/derkalle4/python3-idotmatrix-library/blob/main/idotmatrix/modules/image.py#L123

replace line 123

await self.conn.send(data=data)

with

                    chunks = self._splitIntoChunks(data, 512)
                    for chunk in chunks:
                        await self.conn.send(data=chunk)

so far its worked on every test image I've done, up scaling from 16x16 though is a blur and not very nice

After other have confirmed this works, will formalize a PR to get this corrected

@creathinq
Copy link

@ellensp for me, it does not. I might have an error somewhere else, but I cant find it - might be in the script I use to send PNG, but I cant see there a reason for this irregular behavior.

import asyncio
from idotmatrix import ConnectionManager
import sys
import logging

async def main():
    conn = ConnectionManager()
    await conn.connectByAddress("97:2F:37:66:D5:98")
    from idotmatrix import Image
    image = Image()
    await image.setMode(1)
    await image.uploadProcessed(sys.argv[1], 32)
    #await image.uploadUnprocessed(sys.argv[1])

if __name__ == "__main__":
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        quit()

and the result is the same, only duck with 32x32 size works.

pi@rpi0w:~/idotmatrix $ ./my-venv/bin/python png.py ./images/demo_16.png
20.11.2024 08:56:09 :: DEBUG :: asyncio :: Using selector: EpollSelector
20.11.2024 08:56:11 :: INFO :: idotmatrix.connectionManager :: connected to 97:2F:37:66:D5:98
20.11.2024 08:56:11 :: DEBUG :: idotmatrix.connectionManager :: sending message(s) to device
20.11.2024 08:56:11 :: DEBUG :: PIL.PngImagePlugin :: STREAM b'IHDR' 16 13
20.11.2024 08:56:11 :: DEBUG :: PIL.PngImagePlugin :: STREAM b'pHYs' 41 9
20.11.2024 08:56:11 :: DEBUG :: PIL.PngImagePlugin :: STREAM b'IDAT' 62 181
20.11.2024 08:56:11 :: DEBUG :: idotmatrix.connectionManager :: sending message(s) to device
20.11.2024 08:56:11 :: ERROR :: idotmatrix.modules.image :: could not upload processed image: [org.bluez.Error.Failed] Failed to initiate write

pi@rpi0w:~/idotmatrix $ ./my-venv/bin/python png.py ./images/demo_32.png
20.11.2024 08:56:19 :: DEBUG :: asyncio :: Using selector: EpollSelector
20.11.2024 08:56:20 :: INFO :: idotmatrix.connectionManager :: connected to 97:2F:37:66:D5:98
20.11.2024 08:56:20 :: DEBUG :: idotmatrix.connectionManager :: sending message(s) to device
20.11.2024 08:56:21 :: DEBUG :: PIL.PngImagePlugin :: STREAM b'IHDR' 16 13
20.11.2024 08:56:21 :: DEBUG :: PIL.PngImagePlugin :: STREAM b'pHYs' 41 9
20.11.2024 08:56:21 :: DEBUG :: PIL.PngImagePlugin :: STREAM b'IDAT' 62 352
20.11.2024 08:56:21 :: DEBUG :: idotmatrix.connectionManager :: sending message(s) to device

pi@rpi0w:~/idotmatrix $ ./my-venv/bin/python png.py ./images/demo_64.png
20.11.2024 08:56:27 :: DEBUG :: asyncio :: Using selector: EpollSelector
20.11.2024 08:56:29 :: INFO :: idotmatrix.connectionManager :: connected to 97:2F:37:66:D5:98
20.11.2024 08:56:29 :: DEBUG :: idotmatrix.connectionManager :: sending message(s) to device
20.11.2024 08:56:29 :: DEBUG :: PIL.PngImagePlugin :: STREAM b'IHDR' 16 13
20.11.2024 08:56:29 :: DEBUG :: PIL.PngImagePlugin :: STREAM b'pHYs' 41 9
20.11.2024 08:56:29 :: DEBUG :: PIL.PngImagePlugin :: STREAM b'IDAT' 62 442
20.11.2024 08:56:29 :: DEBUG :: idotmatrix.connectionManager :: sending message(s) to device
20.11.2024 08:56:29 :: ERROR :: idotmatrix.modules.image :: could not upload processed image: [org.bluez.Error.Failed] Failed to initiate write

@ellensp
Copy link

ellensp commented Nov 20, 2024

you have not updated the library code.

should have multiple sending message(s) lines as most images exceed 512 bytes

your lib is in something like my-venv/lib/python3.12/site-packages/idotmatrix/modules/image.py

I just created your script

and here is my log (a few extra debug statements than you will have)

python png.py ./images/demo_64.png

20.11.2024 21:20:17 :: DEBUG :: asyncio :: Using selector: EpollSelector
20.11.2024 21:20:19 :: INFO :: idotmatrix.connectionManager :: connected to 0E:81:B3:86:B3:54
20.11.2024 21:20:19 :: DEBUG :: idotmatrix.connectionManager :: sending message(s) to device
20.11.2024 21:20:19 :: DEBUG :: idotmatrix.modules.image :: Processing image
20.11.2024 21:20:19 :: DEBUG :: PIL.PngImagePlugin :: STREAM b'IHDR' 16 13
20.11.2024 21:20:19 :: DEBUG :: PIL.PngImagePlugin :: STREAM b'pHYs' 41 9
20.11.2024 21:20:19 :: DEBUG :: PIL.PngImagePlugin :: STREAM b'IDAT' 62 442
20.11.2024 21:20:19 :: DEBUG :: idotmatrix.modules.image :: img: <PIL.Image.Image image mode=RGBA size=32x32 at 0x728DE3930350>
20.11.2024 21:20:19 :: DEBUG :: idotmatrix.modules.image :: resized img.size: (32, 32)
20.11.2024 21:20:19 :: DEBUG :: idotmatrix.connectionManager :: sending message(s) to device
20.11.2024 21:20:19 :: DEBUG :: idotmatrix.connectionManager :: sending message(s) to device
20.11.2024 21:20:19 :: DEBUG :: idotmatrix.connectionManager :: sending message(s) to device

@creathinq
Copy link

dammit, I updated the wrong lib, outside of venv.

now it works, with all the ducks and any other images.

Thank you!

@ellensp
Copy link

ellensp commented Nov 20, 2024

I have found the odd few images that still will not upload, unknown as to why. another limit somewhere probably.

@starvald
Copy link

Only using GIF's for now and after testing PNG's same problem here.

There are cheap 64x64 LED panels now available which seem to use the same protocol and app... anyone tried those yet?

I have one on the way.

@starvald
Copy link

64x64 arrived today. haven't tested every option.
setting the clock mode works

uploading the demo.gif works but can't set the demo images.

[lee@Plasma python3-idotmatrix-client]$ ./run_in_venv.sh --address B7:8B:55:70:76:3E --set-gif ./images/demo.gif --process-gif 64
23.11.2024 10:26:52 :: INFO :: idotmatrix :: initialize app
23.11.2024 10:26:52 :: INFO :: idotmatrix.core.cmd :: initializing command line
23.11.2024 10:26:52 :: DEBUG :: idotmatrix.core.cmd :: using --address
23.11.2024 10:26:53 :: INFO :: idotmatrix.connectionManager :: connected to B7:8B:55:70:76:3E
23.11.2024 10:26:53 :: INFO :: idotmatrix.core.cmd :: setting (animated) GIF
23.11.2024 10:26:53 :: DEBUG :: idotmatrix.connectionManager :: sending message(s) to device

[lee@Plasma python3-idotmatrix-client]$ ./run_in_venv.sh --address B7:8B:55:70:76:3E --image true --set-image ./images/demo_64.png
23.11.2024 10:27:45 :: INFO :: idotmatrix :: initialize app
23.11.2024 10:27:45 :: INFO :: idotmatrix.core.cmd :: initializing command line
23.11.2024 10:27:45 :: DEBUG :: idotmatrix.core.cmd :: using --address
23.11.2024 10:27:46 :: INFO :: idotmatrix.connectionManager :: connected to B7:8B:55:70:76:3E
23.11.2024 10:27:46 :: INFO :: idotmatrix.core.cmd :: setting image
23.11.2024 10:27:46 :: DEBUG :: idotmatrix.connectionManager :: sending message(s) to device
23.11.2024 10:27:46 :: DEBUG :: idotmatrix.connectionManager :: sending message(s) to device
23.11.2024 10:27:46 :: ERROR :: idotmatrix.modules.image :: could not upload the unprocessed image: [org.bluez.Error.Failed] Failed to initiate write

[lee@Plasma python3-idotmatrix-client]$ ./run_in_venv.sh --address B7:8B:55:70:76:3E --image true --set-image ./images/demo_64.png --process-image 64
23.11.2024 10:28:05 :: INFO :: idotmatrix :: initialize app
23.11.2024 10:28:05 :: INFO :: idotmatrix.core.cmd :: initializing command line
23.11.2024 10:28:05 :: DEBUG :: idotmatrix.core.cmd :: using --address
23.11.2024 10:28:07 :: INFO :: idotmatrix.connectionManager :: connected to B7:8B:55:70:76:3E
23.11.2024 10:28:07 :: INFO :: idotmatrix.core.cmd :: setting image
23.11.2024 10:28:07 :: DEBUG :: idotmatrix.connectionManager :: sending message(s) to device
23.11.2024 10:28:07 :: DEBUG :: PIL.PngImagePlugin :: STREAM b'IHDR' 16 13
23.11.2024 10:28:07 :: DEBUG :: PIL.PngImagePlugin :: STREAM b'pHYs' 41 9
23.11.2024 10:28:07 :: DEBUG :: PIL.PngImagePlugin :: STREAM b'IDAT' 62 442
23.11.2024 10:28:07 :: DEBUG :: idotmatrix.connectionManager :: sending message(s) to device
23.11.2024 10:28:07 :: ERROR :: idotmatrix.modules.image :: could not upload processed image: [org.bluez.Error.Failed] Failed to initiate write

[lee@Plasma python3-idotmatrix-client]$ ./run_in_venv.sh --address B7:8B:55:70:76:3E --image true --set-image ./images/demo_32.png --process-image 64
23.11.2024 10:28:25 :: INFO :: idotmatrix :: initialize app
23.11.2024 10:28:25 :: INFO :: idotmatrix.core.cmd :: initializing command line
23.11.2024 10:28:25 :: DEBUG :: idotmatrix.core.cmd :: using --address
23.11.2024 10:28:26 :: INFO :: idotmatrix.connectionManager :: connected to B7:8B:55:70:76:3E
23.11.2024 10:28:26 :: INFO :: idotmatrix.core.cmd :: setting image
23.11.2024 10:28:26 :: DEBUG :: idotmatrix.connectionManager :: sending message(s) to device
23.11.2024 10:28:26 :: DEBUG :: PIL.PngImagePlugin :: STREAM b'IHDR' 16 13
23.11.2024 10:28:26 :: DEBUG :: PIL.PngImagePlugin :: STREAM b'pHYs' 41 9
23.11.2024 10:28:26 :: DEBUG :: PIL.PngImagePlugin :: STREAM b'IDAT' 62 352
23.11.2024 10:28:26 :: DEBUG :: idotmatrix.connectionManager :: sending message(s) to device
23.11.2024 10:28:26 :: ERROR :: idotmatrix.modules.image :: could not upload processed image: [org.bluez.Error.Failed] Failed to initiate write

IMG_20241123_102116_879

@derkalle4
Copy link
Owner

Hi all,
many thanks for your help! Still having ongoing issues with long-covid. Nevermind, I have pushed the 0.0.8 of the iDotMatrix-Library to pip -> https://github.com/derkalle4/python3-idotmatrix-library/releases/tag/v0.0.8 therefore the improvements are deployed!

I got another 64 Pixel display about half a year ago and it worked exactly the same like my 32 pixel display. Just another brand where each LED pixel is visible (no plastic diffusor in front).

Is it the same app? Maybe there are some differences.

@TomCat666
Copy link
Author

Ordered the 64x64 one with diffusor. If GIF loading works it is enough for me... :)

@bviksoe
Copy link

bviksoe commented Dec 20, 2024

Hi,

Was playing around with this. First of all: thanks for this project; it saved me from installing the app on my phone.

However I am experiencing the same problems on Windows. I'm even getting:

python app.py --address 11:22:33:44:55:66 --set-text "Hello123" --text-size 32 --text-mode 1 --text-speed 100
...
20.12.2024 22:17:51 :: ERROR :: idotmatrix.modules.text :: could send the text to the device: [WinError -2147024809] Wrong argument

when trying to set a scrolling text beyond length "hello12". However, the _splitIntoChunks trick worked on that module too.

I suggest:

  1. Remember to upgrade pyproject.toml to 0.0.8 version in this repo too.
  2. Refactor code so the splitIntoChunks is in connectionManager.py ConnectionManager.send

@ZiadGhanem
Copy link

Hello,

I can also confirm that splitting the data into chuncks worked for me too.

Thanks

@derkalle4
Copy link
Owner

Thanks for the feedback. Will look into improving this :)

@LostQuasar
Copy link

The only image I have managed to write to the display is demo_32.png any other image simple fails including images that are far smaller than demo_32.png

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

8 participants