Repository navigation
Description
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:
1- Gather the selected PC info.
2- Render a full image in BBGGRRAA format.
2a- Play the Video (if one was set as a background).
3- Send the rendered image using a "Full_Image" command.
Then loop the following:
4- Gather PC info again.
5- Render another full image.
6- Compare it with the current image, then generate the changed-pixels message.
7- Send the changed-pixels message using an "Update_Image" command.
8- Apply the changes to the image stored in the app so it can be synced with the monitor.
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:
S=starting pixel position
C=Count, how many pixels
P=PixelColors in BBGGRR format
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):
- Full-Image message:
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
- Changed-pixels message:
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 app always starts with the "Get_Device" command, might be used to determine the supported commands, or it could also functions as an initialize command.
- There are commands that the app sends but don't seem to do anything (I can skip them with no visible problems).
- All messages must be 250 bytes of size, or multiple of it.
- All commands must be 250 bytes by themselves, so they must be padded without counting other messages within them.
- Every 250th byte is unused, so an extra byte must added.
- Every reply from the monitor (except for two commands, "Get_Device" and "query storage usage") is padded to 1024 bytes.
- The amount of transparent pixels will affect the frame-rate of the video background.
- Some commands can be truncated and still work, but I opted to list them as the app sent them.
Activity
MrFr1day commentedon Nov 22, 2022
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?
gerph commentedon Nov 22, 2022
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!
arthurferrai commentedon Apr 4, 2023
I have one of these, and I think I can help reverse-engineering this display... Which data sniffer are you using?
MrFr1day commentedon Apr 5, 2023
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.
sambasan commentedon Apr 18, 2023
Thank you very much for the reverse engineering work so far.
I'm currently writing 5" display support for this software. Still at prototype level and can take some time to finish but anyways. The plan is to also support video backgrounds in themes.
I've also got the display and can help reverse engineer the commands a bit further if needed.
I'm using a generic serial analyzer software that can tap into the communication that is happening on USB over the CDC driver.
Findings so far:
All commands requiring path, for example:
6e ef 69 00 00 00 13 00 00 00 (P)Actually have the path length in characters, meaning that the correct decoding would be:
6e ef 69 00 00 00 (L) 00 00 00 (P)L: Path length in characters for example for /mnt/SDCARD/video/earth.mp4 this would be 1b (dec: 27)
P: Path itself (ascii encoded to hex)
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:
6f ef 69 00 00 00 (L) 00 00 00 (P) (V)L: Path length in characters for example for /mnt/SDCARD/video/earth.mp4 this would be 1b (dec: 27)
P: Path itself (ascii encoded to hex)
V: Video bytes count with endianness flipped so video with 1069828 bytes (105304 hex) would be 045310 hex you can do this with:
struct.pack('<i', video_size_bytes).hex()Code I used to split the video file to chunks:
Notes:
I expect these to work pretty similarly for internal / SD card storage with only path being the differing part.
alexwbaule commentedon May 24, 2023
Can i help with this ? I buy it one with 5 pol screen.
I made a usbcap in windows to get commands, etc....
alexwbaule commentedon May 25, 2023
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 ?
arthurferrai commentedon May 26, 2023
That's what we have for now... The original executable is obfuscated, so it's a mess to read.
alexwbaule commentedon May 26, 2023
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.
ErikApption commentedon May 26, 2023
@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
alexwbaule commentedon May 29, 2023
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".
(stream file)
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).
(usb.transfer_type == URB_BULK and usb.irp_info.direction == 0 and usb.endpoint_address.direction == 0) or (usb.transfer_type == URB_BULK and usb.irp_info.direction == 1 and usb.endpoint_address.direction == 1)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:
"C:\Program Files\Wireshark\tshark.exe" -T fields -e usb.irp_info.direction -e usb.capdata -r All.pcapngThe
usb.irp_info.directioninform the direction (0x00 from your host | 0x01 from your screen device), and theusb.capdatais the "stream" itself.What i found ? just one command that is
7b ef 69(set the brightness) before thePostImgCMD.I tried to use the
GenerateUpdateImagein a loop, but at the second time that i call, the "needReSend" is allways 1, and i cant update the image (i build 3 equals images, with the number 1, 2 and 3), but using the captured stream, the update works ok, so, there is something missing that i can't say what is LOL....If someone can help to reverse this stream to some "image file" (maybe doing the reverse of
GenerateUpdateImagedoes)...alexwbaule commentedon May 30, 2023
Hi...
Using this
https://github.com/icsharpcode/ILSpy/releases/tag/v8.0
@arthurferrai and @ErikApption
I get some decompiled itens , show the draw itens, etc, some strings to send command.
To get all strings, its easy, the function is in the code.
All the strings that has the
global::쏔.b("<OBFUSCATED STRING>", a_);thea_is in the start of the function, like here:I Dont have .NET installed in my Windows, so i cant rebuild the strings... but i think its a start point.
sambasan commentedon May 30, 2023
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 😄
33 remaining items
alexwbaule commentedon Jun 5, 2023
I sended a invite to you , accept and you can write to the repo.
alexwbaule commentedon Jun 5, 2023
If you write your modifications in the original branch (working/support-5-inches-device) the PR will be updated.
arthurferrai commentedon Jun 5, 2023
Done.
@alexwbaule (and anyone else), please test to see if I did it correctly :)
alexwbaule commentedon Jun 5, 2023
Tks @arthurferrai !
I will test it now...
alexwbaule commentedon Jun 5, 2023
Its Working here...
For me, thats fine... the PR is open, and with our commits.
gwendal-h commentedon Oct 3, 2023
Hello, I just added a pull request for the video support: #348
I still have to improve the performance: the refresh is a bit slow and it takes too much CPU.
sambasan commentedon Oct 4, 2023
Looks awesome @gwendal-h. I got stuck with the video visible pixel color format but it seems you figured it out. Nice!
gwendal-h commentedon Oct 5, 2023
Small video example :
20231005.195201.mp4
gwendal-h commentedon Oct 5, 2023
There's 1 issue left :
Sometimes the update of the text/image freezes. And the status reply is "NeedReSend = 1" ...
I still have to investigate a bit on that. I suspect an ill-formed message.
Performance benchmark:
(the more pixels updated the longer it takes, so I'm doing the benchmark with the file "simple-program-video-mode.py")
My first commit, without any optimizations, one refresh takes about 330 ms on my computer.
2nd commit, with a few optimizations one refresh takes about 110 ms
I'm working on a big improvement so far i'm sending the full overlay bitmap + the visible pixels command to perform a refresh.
It is possible to only send the updated pixels + the visible pixels command.
The first tries are encouraging: from 100 000 bytes down to only 10 000 bytes sent on the serial port to perform 1 refresh.
gwendal-h commentedon Oct 8, 2023
Finally fixed the freeze issue, and improved refresh time a lot :
refresh_with_numba.mp4
Goliohs commentedon Sep 24, 2026
For
chs_5inch/ ROM 88 full-image path that actually draws (vs shear stripes):size_fieldis always480*480/64 = 0x0E10, notwidth*width/64.Full write-up: https://github.com/Goliohs/turzx-native-monitor
arthurferrai commentedon Sep 25, 2026
Looks like the link is dead.