Skip to content

Add binary output to stdout#13

Open
kylemanna wants to merge 8 commits intomasterfrom
km/binary-output
Open

Add binary output to stdout#13
kylemanna wants to merge 8 commits intomasterfrom
km/binary-output

Conversation

@kylemanna
Copy link
Copy Markdown
Owner

@kylemanna kylemanna commented Oct 26, 2020

This writes binary output to stdout to it can be piped to another program or to a file.

Closes #10

Quick demo:

$ ls -l test.bin
-rw-r--r-- 1 nitro nitro 64 Oct 25 13:43 test.bin
$ python3 -m devmem -s 4 -n 16 -r 0 -m test.bin -b  | sha1sum
2a30a4a80820710bf0335bae7e35e11c5ee1ab41  -
$ sha1sum test.bin                                     km/binary-output ◼
2a30a4a80820710bf0335bae7e35e11c5ee1ab41  test.bin

@kylemanna kylemanna self-assigned this Oct 26, 2020
@psolyca
Copy link
Copy Markdown

psolyca commented Oct 26, 2020

I have tested it but I had to change a little thing ^^;
You use function annotations which is a Python 3 feature and my platform is stucked in Python 2.7.
I do not know yet if I could update to Python 3 (I need to look for incompatibilities).

BTW, always MemoryError, line 138 of __init__.py. I think I do not have enough RAM to load all the dump.
So it should be ok for others but not for me :p

EDIT :
In Python 2.7, sys.stdout as no buffer attribut
Ok I change the size settings (-s) to 1 and the script runs ok.
BTW, the result is not the expected one !! The file begin with a debug line from the script itself. Maybe some memory trouble in my side.
BUT the script is running.

@kylemanna
Copy link
Copy Markdown
Owner Author

@psolyca I could look at a python generator that would stream maybe 1MB at a time, would that work?

I can drop the type hinting, for python2

@kylemanna
Copy link
Copy Markdown
Owner Author

Also if you give me more details about the debugging output you're seeing and the changes you've had to made I can incorporate them in to an update to this PR.

Comment thread devmem/__main__.py Outdated
@psolyca
Copy link
Copy Markdown

psolyca commented Oct 26, 2020

The review and the type hinting are the only modifications I have made.
The following lines are in my dump.

DevMem Debug: init with base_addr = 0x824000 and length = 0x12dc000 on /dev/mem
DevMem Debug: reading 19771544 bytes from offset 0x0

After, it seems that the memory dump is the same as the other method.
This "artefact" of the command line has already append but each time I had deleted the file I was overwriting and that disappeared. Not this time !
I will do more dump to compare.

@kylemanna
Copy link
Copy Markdown
Owner Author

The following lines are in my dump.

Are you passing -d/--debug to devmem? I suspect you are as that's what should enable those outputs. They should be printed to stderr though.

* Formerly the data buffer was a list of integers.
* This seems to more accurately reflect memory and is probably faster
  and more efficient.
* Hopefully makes supporting 64-bit reads/writes easier
* Format with `black` again.
* Make it simple to stream data to another program or write to a file.
* Otherwise there's a chance to mix the binary output with the debug
  output if piped to another program or redirected to a file.
* Some embedded platforms are still on Python 2.7 :(
@psolyca
Copy link
Copy Markdown

psolyca commented Oct 26, 2020

Yes I was using --debug.

Last version is working as expected.
Lol I am sorry to use Python 2.7, the platform is an action cam, I am sure I can change the Python version but I do not know if this is really usefull.

@rhollen
Copy link
Copy Markdown

rhollen commented Oct 26, 2020

Can you add something to the setup.py to explain which versions of python are supported? From there it appears that only 3.8 is supported.

@kylemanna
Copy link
Copy Markdown
Owner Author

Can you add something to the setup.py to explain which versions of python are supported? From there it appears that only 3.8 is supported.

Yup, need to add some tests and CI via Github Actions since testing Python 2 is getting harder these days. My dev machine doesn't have Python 2 at all these days.

@rhollen Are you running this on a sad Python 2 embedded device?

@rhollen
Copy link
Copy Markdown

rhollen commented Oct 27, 2020

Can you add something to the setup.py to explain which versions of python are supported? From there it appears that only 3.8 is supported.

Yup, need to add some tests and CI via Github Actions since testing Python 2 is getting harder these days. My dev machine doesn't have Python 2 at all these days.

@rhollen Are you running this on a sad Python 2 embedded device?

I haven't tested yet, but I will be using python 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants