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

Sending packet 0x6D corrupts the data. (0x6D - All-In-View Satellite Selection) #33

Open
sdroovan opened this issue Mar 12, 2018 · 5 comments

Comments

@sdroovan
Copy link

sdroovan commented Mar 12, 2018

When creating a packet 0x6D and send it over RS232, it modifies the data incorrectly.

fixmode = (0x04 | ((g.num_sat)<<4))
command = tsip.Packet(0x6D, fixmode,0,0,0,0, *fields)				
gps_conn.write(command)
@mjuenema
Copy link
Owner

Hi, can you provide some more detail please. What is the expected outcome and what is the actual outcome?

@sdroovan
Copy link
Author

sdroovan commented Mar 19, 2018

Hi, I did some more debugging, and I guess the structure is not well defined.
See structs.py. Below you find the lines I corrected (see #<------).

class Struct0x6d(object):
    """Report Packet 0x6D: Satellite Selection List.

       This packet is of variable length equal to 5+nsvs where "nsvs" is
       the number of satellites used in the solution.

    """

    def pack(self, *f):
        fmt = '>BBffff' + 'b' * (len(f) - 6)                                             #<------
        return struct.pack(fmt, *f)

    def unpack(self, s):
        fields = [0x6d] + list(struct.unpack('>BBffff', s[1:18]))                        #<------
        nsvs = (fields[0] & 0b11110000) >> 4

        try:
            s = s[18:]
            for n in range(0, nsvs):
                fields.append(struct.unpack('>b', s[n])[0])
        except IndexError:
            # Occasionally `s` doesn't seem to be long enough
            # so in this case instead of causing an exception we
            # simply return the data so far.
            pass

        return fields

@mjuenema
Copy link
Owner

0x6d is an output packet which is a response to command packet 0x24. Is there a reason, why you want to send 0x6d?

@sdroovan
Copy link
Author

I use it to simulate a gps receiver directly. So I just use the lib as a (gps) packet sender (not receiver).

@mjuenema
Copy link
Owner

Nice! I haven't thought of that. I am going to look into it.

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

No branches or pull requests

2 participants