-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
5" Commands #90
Comments
Here is a working example (for an image background, and based on how their app communicate with the monitor):
As you have guessed by now, I'm not a programmer by trade, and this is my first Python code, and working with hex, images, and serial-comms in this way, so I want to ask, did I waste my time decoding a known-standard for their changed-pixels messages, or did they actually make their own? Also, using the code I posted, it takes about 0.6 seconds to convert and send a full image (800x480), is this monitor faster than the 3.5 model? |
That's an impressive amount of decoding for the device, and it seems a little different to the interface that we've seen so far. I've got a device on order so fingers crossed I'll be able to play with that 'soon' (for whatever value of 'soon' AliExpress can give me!). Well done in getting that far - it looks very useful to produce an update to the libraries! |
I have one of these, and I think I can help reverse-engineering this display... Which data sniffer are you using? |
Thanks for the offer, but as I said in the OP, aside from adding media files to it, I think I've already decoded all the commands, and I've been using it for some time now. |
Thank you very much for the reverse engineering work so far. Findings so far:
Actually have the path length in characters, meaning that the correct decoding would be: Additionally I decoded the video upload process and got a simple upload script working. I'll post the full code example a bit later but in general it goes like this:
Upload video command:
Code I used to split the video file to chunks: def read_in_chunks(file_object, chunk_size=249):
while True:
data = file_object.read(chunk_size)
if not data:
break
yield data
def upload_video(local_path):
with open(local_path, "rb") as video_file:
for packet in read_in_chunks(video_file):
send_msg(packet) Notes: I expect these to work pretty similarly for internal / SD card storage with only path being the differing part. |
Can i help with this ? I buy it one with 5 pol screen. I made a usbcap in windows to get commands, etc.... |
I want to stick with python , im using linux, and i want to make this work on it. There is some reverse engineering processing or some documentation about the 5 pol device ? Using the code that @MrFr1day write, change port, its worked. But, there is more commands to get ? |
That's what we have for now... The original executable is obfuscated, so it's a mess to read. |
Im doing some reverse engineering with the original executable, and wireshark capturing usb packs. When i finish i will post here. I found some news about play videos, and another things. |
@alexwbaule - what is missing from the code from @MrFr1day? I also tried reverse engineering the original code but it has been obfuscated so it was not very helpful imo |
Ok ! Lets share what i found until now....
With this code (sorry !! im not a python coder or developer) and this file in attachment, you can "play a update image stream". How i get this file ? Using wireshark + some commands to export. First, set this filter on wireshark (and use one port with only one item attached).
Second, with the "action" that you want to capture done, you can save this capture. (stop the capture before, and go to File -> Export Specified Packages). Once you saved the capture, you can run this command to save only the streaming:
The What i found ? just one command that is I tried to use the If someone can help to reverse this stream to some "image file" (maybe doing the reverse of |
Hi... Using this @arthurferrai and @ErikApption
All the strings that has the I Dont have .NET installed in my Windows, so i cant rebuild the strings... but i think its a start point. |
Hi, I just wanted to clarify that it is possible to send only the changed pixels over and over again if you set the index (serial number V in MrFr1day notes) properly in the changed pixels update command itself. It is possible to use a running number (bigger than the last one sent) It's what I'm currently doing in the prototype implementation. I'm currently close to getting the driver to do changed pixels over video background. Also the currenty used serial device locking does seem to work properly for queuing up the display commands between the threads even with index with some modifications. I can share the code in my fork repo in few days if needed for reference. Not ready for a pull request yet though 😄 |
Are you sending exactly the same stream? I mean, it looks like it's struggling with "cleanup". Do you need to send BG pixels again? What happens if a video is playing? |
I sended exactly the same stream, you can see it on my post. What i can sended is the "Full image background" i dont know whats happens with the stream, its dont receive the "full_png_success". If i remove the background from the stream, works exactly what you see in the video. |
I build a version with support to 5 inch. https://github.com/alexwbaule/turing-smart-screen-python/tree/support-5inch Its UGLY, but, its work, with some bugs... Its in my fork. |
I'll give a try. |
I dont edit the simple_program.py, i create a new lcd_comm_rec_c.py , and change somethigs to work with this modifications. So, if you call main.py, it will work. |
@arthurferrai my branch has a lot of debug info, some stdout writes to see the hex... you can comment this itens. |
You can pull from my repo now, i add in configure.py and simple-program.py the 5inch item. Please, use the LandscapeEarth_5Inch theme, all 3.5 themes will not work. |
I'll assume I need to change to
Looks like |
My bad... its there now, you can pull |
@arthurferrai , change to this "support-5-inches-device" branch. All 3.5 themes are imcompatible, the sizes dont match. This repo has 2 themes that support the 5 inch. |
Is it |
Done... pull please. |
Right, I tried both I think it might be an issue on trying to send data to serial port. |
Lets update the thread. I "finished" the implementation. (Tested on Linux and Windows). What is working ?
What is missing ?
There is some catchs. You can edit any theme, just change the image to 480 x 800 or 800 x 480. If you try to use the 3.5 image, the image will not be showed. I merged in my "master" branch, in my repo. https://github.com/alexwbaule/turing-smart-screen-python With this "status", i can do a Pull Request to merge with this repo ? @mathoudebine |
I tried |
You are using the correct background image ? (480 x 800 or 800 x 480) get the last commits , with a pull ? (now i dont save images anymore.) You see this in the log ?
And After this (in this order, ignoring another itens):
|
Nope, my log shows something like this:
Edit: I'm a dumb and was using wrong COM port :P |
Sorry about the mess, it's working nicely here. |
Just looking through dependencies, I think it would be nice to drop numpy and opencv dependencies (especially opencv is a HUGE library)... I might try to do that if you don't mind :D |
Go a head, i use opencv because i dont have the knowledge to work with Pil Package only, to make the images. |
I succeeded to remove opencv and numpy dependencies. the only problem is the color space conversion on this display (BGR) that is not ideal on Pillow (it works, but it's a bit inefficient, will try to improve later on). Another thing that I noticed is that it doesn't shut down the display on exit (on my machine, it stays on after pc shuts down). |
The shutdown is commented on the code, but its there. When you turn off the display, to start again you need to re-initialize the connection. |
The auto-detect works on your environment? Asking because I think |
I set the port directly, the AUTO doesn't work for me. |
Did you gave me write access to your repo? Or should I fork yours? |
I sended a invite to you , accept and you can write to the repo. |
If you write your modifications in the original branch (working/support-5-inches-device) the PR will be updated. |
Done. |
Tks @arthurferrai ! I will test it now... |
Its Working here... For me, thats fine... the PR is open, and with our commits. |
Hello, I just added a pull request for the video support: #348 |
Looks awesome @gwendal-h. I got stuck with the video visible pixel color format but it seems you figured it out. Nice! |
Small video example : 20231005.195201.mp4 |
There's 1 issue left : Performance benchmark: My first commit, without any optimizations, one refresh takes about 330 ms on my computer. I'm working on a big improvement so far i'm sending the full overlay bitmap + the visible pixels command to perform a refresh. The first tries are encouraging: from 100 000 bytes down to only 10 000 bytes sent on the serial port to perform 1 refresh. |
Finally fixed the freeze issue, and improved refresh time a lot : refresh_with_numba.mp4 |
Hi,
Following @gerph suggestion, I managed to get, and test most commands (as far as I know, only "add-file" is missing), I can't implement this in code for the library, but I can post what I know, and test if you implement it.
Based on my tests, I think the way their app (UsbMonitorL) works is something like this:
General Commands:
Get the device name/type and firmware (and maybe initialize):
01 ef 69 00 00 00 01 00 00 00 c5 d3
Set brightness, L=1-255:
7b ef 69 00 00 00 01 00 00 00 (L)
Set options, M=StartMode(1=Default, 2=PlayImage, 3=PlayVideo), F=Album-Flip 180 (1=Enable), S=SleepAfter in minutes (0=Disabled, app range 1-10):
7d ef 69 00 00 00 05 00 00 00 2d (M) 00 (F) (S)
TurnOff monitor (it will change it's port number):
83 ef 69 00 00 00 01
Restart monitor:
84 ef 69 00 00 00 01
Storage Commands:
Query Internal/SDCard storage usage, the reply is (InternalTotal-InternalUsed-InternalFree-SDTotal-SDUsed-SDFree):
64 ef 69 00 00 00 01
List Images/Videos in Internal Storage (the folder structure is already created), the reply is a list of files (result:dir:file:f1.ext/f2.ext/fN+.ext/):
65 ef 69 00 00 00 0a 00 00 00 2f 72 6f 6f 74 2f 69 6d 67 2f
65 ef 69 00 00 00 0c 00 00 00 2f 72 6f 6f 74 2f 76 69 64 65 6f 2f
List Images/Videos in SD Card:
65 ef 69 00 00 00 10 00 00 00 2f 6d 6e 74 2f 53 44 43 41 52 44 2f 69 6d 67 2f
65 ef 69 00 00 00 12 00 00 00 2f 6d 6e 74 2f 53 44 43 41 52 44 2f 76 69 64 65 6f 2f
Get a video file size P=Path, the reply is the size in bytes:
6e ef 69 00 00 00 13 00 00 00 (P)
Delete a video file, P=Path:
66 ef 69 00 00 00 14 00 00 00 (P)
Media Commands:
Play Video, P=Path, the reply is (play_video_success):
78 ef 69 00 00 00 13 00 00 00 (P)
Stop Video:
79 ef 69 00 00 00 01
Display a full image (for an image background):
c8 ef 69 00 17 70
Display an initial full image overlay (for a video background):
ca ef 69 00 17 70
Display a changed-pixels image (for an image background), S=Image-message bytes count (2bytes), N=Serial number of the image starting from 0 (4bytes):
cc ef 69 00 00 (S) 00 00 00 (N)
Display a changed-pixels image (for a video background), S=Image-message bytes count (2bytes), N=Serial number of the update starting from 0 (4bytes), V=visible-pixels info bytes count (4bytes):
cc ef 69 00 00 (S) 00 00 00 (N) 00 00 (V)
Query monitor render status, reply is (needReSend:0|renderCnt:X), "needReSend" will be 1 if a changed-pixels message was missed, and "renderCnt" will increase with each frame rendered by the monitor it self:
cf ef 69 00 00 00 01
Image Messages (for an image background):
Full-Image message:
Basically, list all the pixels in BBGGRRAA hex format (e.g blue: FF0000FF)
Changed-pixels message:
S(6bytes) C(4bytes) P(6bytes per pixel), where:
There is no X and Y, so the (S) value must be calculated (S = ((X * 800) + Y), e.g. to display 3 White pixels starting at X=20, Y=30:
003E9E 0003 ffffff ffffff ffffff
If it's only a single pixel, then the count variable (C) is omitted, and the position variable's (S) first hex digit is set to "8", e.g. to display a single White pixel at X=20, Y=30:
803E9E ffffff
Image Messages (for a video background):
Same as the Image-background, but an extra command is needed to define the visible pixels, V=visible-pixels-info bytes count (4bytes):
d0 ef 69 00 00 (V)
As for the visible-pixels-info itself, it's the same as the changed-pixels message, but without the PixelColors variable (P), then it needs to end with "00ef69", e.g. to make only 3 pixels visible starting at X=20, Y=30:
003E9E 0003 00ef69
It differ from the Image-background version in two ways:
1- Just like the Full-Image, the visible pixels needs to be appended to the message
2- The Alpha channel is somehow added to the pixel colors (BBGGRR) value, but I don't know how exactly, my guess from my tests is that the Alpha channel hex digits replaces the second hex digit of Blue and Green channels.
Note that any pixel not defined in the "visible-pixels-info" will not be shown, regardless of its transparency, and any pixel added at any point can be set to visible/hidden at any changed-pixels message.
In other words, not marking a pixel as visible, does not delete it, just hides it until set to visible again by a changed-pixels message.
Notes:
The text was updated successfully, but these errors were encountered: