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

interface to deal with fixed erasures #27

Open
Sec42 opened this issue Sep 13, 2020 · 1 comment
Open

interface to deal with fixed erasures #27

Sec42 opened this issue Sep 13, 2020 · 1 comment

Comments

@Sec42
Copy link

Sec42 commented Sep 13, 2020

This is more a feature request. I have a RS encoding that is a bit strange. It uses 8 bytes of error correction, but instead of the expected encoding:

rs8a=reedsolo.RSCodec(nsym=8, fcr=0, prim=0x11d, c_exp=8)

it instead encodes for 16 bytes, but omits the last 8 bytes from the message.

Due to the way that reed-solomon can deal with known erasures it has the same correcting capabilities as the "standard" one.

I have written a small helper function to deal with this case:

# data: 31B, checksum: 8B, erasure: 8B - RS(47,31) - transmission omits last 8B
rs8=reedsolo.RSCodec(nsym=(8+8), fcr=0, prim=0x11d, c_exp=8)
rs8.elen=8

def decode_with_fixed_erasure(self, data, nsym=None, erase_pos=None, only_erasures=False):
    if nsym is None: nsym=self.nsym

    if self.elen > 0:
        data=data+([0]*self.elen)
        r=range(len(data)-self.elen,len(data))
        if erase_pos is None:
            erase_pos=r
        else:
            erase_pos=list(set(r)|set(erase_pos))
        (cmsg,crs,ep)=self.decode(data, nsym, erase_pos=erase_pos, only_erasures=only_erasures)
        return (cmsg, crs, bytearray(set(ep)-set(r)))
    else:
        return self.decode(data, nsym, erase_pos, only_erasures)

I wonder if this is something you would consider adding support for.

@lrq3000
Copy link
Collaborator

lrq3000 commented Dec 8, 2022

Thank you for your suggestion and for sharing your code. I won't be the one implementing it, but I leave your issue open if someone else want to give it a try or has similar needs.

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

No branches or pull requests

2 participants