Hello,
I'm tring to make a cutting script.
The problem is the following, i have a sample pattern, for
example :'11101110' (0xEE)
That is the sign of the data begining.
How can i cut a file if the byte stepping is not the same, for
example:
file=open('test.bin','rb')
data=file.read()
print binascii.hexlify(data) # BB9A (1011101110011010)
file.close()
so i need to cut the first two bit and start to writeout the bit
stream to another file
If somebody have an idea to do this, please share with me.
Thanx
Rew 3 1852
On May 29, 9:42�am, "rewo...@gmail.com" <rewo...@gmail.comwrote:
Hello,
I'm tring to make a cutting script.
The problem is the following, i have a sample pattern, for
example :'11101110' (0xEE)
That is the sign of the data begining.
How can i cut a file if the byte stepping is not the same, for
example:
file=open('test.bin','rb')
data=file.read()
print binascii.hexlify(data) � � � � � �# BB9A (1011101110011010)
file.close()
so i need to cut the first two bit and start to writeout the bit
stream to another file
If somebody have an idea to do this, please share with me.
Thanx
Cutting off the leading two bits isn't a problem,
but once you write out the byte 11101110 you are
left with 011010 which cannot be written as it's not
a byte. How do you plan to handle that? Add two bits
at the MSB (00011010) or two bits at the LSB (01101000)
or discard the fractional byte?
And do you always know what the bit offset is or
do you have to search for the 11101110 starting
pattern?
>
Rew
On máj. 29, 18:26, Mensanator <mensana...@aol.comwrote:
On May 29, 9:42�am, "rewo...@gmail.com" <rewo...@gmail.comwrote:
Hello,
I'm tring to make a cutting script.
The problem is the following, i have a sample pattern, for
example :'11101110' (0xEE)
That is the sign of the data begining.
How can i cut a file if the byte stepping is not the same, for
example:
file=open('test.bin','rb')
data=file.read()
print binascii.hexlify(data) � � � � � �# BB9A (1011101110011010)
file.close()
so i need to cut the first two bit and start to writeout the bit
stream to another file
If somebody have an idea to do this, please share with me.
Thanx
Cutting off the leading two bits isn't a problem,
but once you write out the byte 11101110 Â*you are
left with 011010 which cannot be written as it's not
a byte. How do you plan to handle that? Add two bits
at the MSB (00011010) or two bits at the LSB (01101000)
or discard the fractional byte?
And do you always know what the bit offset is or
do you have to search for the 11101110 starting
pattern?
Thank's for the reply,
Yes, I have to search for the pattern, the bit offset not always the
same.
for another thing, it's ok if i can fill up with zero at the LSB or
discard that byte. (the last byte not important)
Rew
On May 30, 9:16*am, Dennis Lee Bieber <wlfr...@ix.netcom.comwrote:
On Thu, 29 May 2008 09:37:54 -0700 (PDT), "rewo...@gmail.com"
<rewo...@gmail.comdeclaimed the following in comp.lang.python:
Thank's for the reply,
Yes, I have to search for the pattern, the bit offset not always the
same.
for another thing, it's ok if i can fill up with zero at the LSB or
discard that byte. (the last byte not important)
* * * * Sounds suspiciously like an HDLC protocol...
* * * * You'll likely need to create a library that can extract the properly
aligned bytes by holding one -- properly shifted -- and fed the next
byte.
* * * * In very loose pseudo-code
detect bit offset
initialize extractor with first valid byte and offset
for inbyte in input:
* * * * outbyte = extract_feed(inbyte)
where extract_feed() shifts the remainder (or first byte) left by the
offset (into a 16bit value), adds the new byte, ANDs with an 8-bit mask
with proper offset, returns left most result byte while also clearing
the remainder portion
--
* * * * Wulfraed * * * *Dennis Lee Bieber * * * * * * * KD6MOG
* * * * wlfr...@ix.netcom.com * * * * * * *wulfr...@bestiaria.com
* * * * * * * * HTTP://wlfraed.home.netcom.com/
* * * * (Bestiaria Support Staff: * * * * * * * web-a...@bestiaria.com)
* * * * * * * * HTTP://www.bestiaria.com/
Thank you for your help, i will try to do something like that.
I did some test about extracting byte with binascii, i will post it
tomorow.
Rew This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Cigdem |
last post by:
Hello,
I am trying to parse the XML files that the user selects(XML files are
on anoher OS400 system called "wkdis3"). But i am permenantly getting
that error:
Directory0: \\wkdis3\ROOT\home...
|
by: Rick Walsh |
last post by:
I have an HTML table in the following format:
<table>
<tr><td>Header 1</td><td>Header 2</td></tr>
<tr><td>1</td><td>2</td></tr>
<tr><td>3</td><td>4</td></tr>
<tr><td>5</td><td>6</td></tr>...
|
by: toton |
last post by:
Hi,
I have some ascii files, which are having some formatted text. I want
to read some section only from the total file.
For that what I am doing is indexing the sections (denoted by .START
in...
|
by: Chris Carlen |
last post by:
Hi:
Having completed enough serial driver code for a TMS320F2812
microcontroller to talk to a terminal, I am now trying different
approaches to command interpretation.
I have a very simple...
|
by: Felipe De Bene |
last post by:
I'm having problems parsing an HTML file with the following syntax :
<TABLE cellspacing=0 cellpadding=0 ALIGN=CENTER BORDER=1 width='100%'>
<TH BGCOLOR='#c0c0c0' Width='3%'>User ID</TH>
<TH...
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
| |