Skip to content

CHAR[5] causes exception if the string is less than 5 characters #15

@e100

Description

@e100

I setup the fixgateway to send the fixid WPNAME using canfix id 1152 ( 0x480) that is identified as CHAR[5]

If WPNAME contains exactly 5 characters it works fine.
If WPNAME contains less than 5 characters this library will throw a "string index out of range" exception at:

x.extend(pack(y[0], value[n], 1))

The obvious fix is to ensure WPNAME is always 5 characters, likely padded with spaces when needed.
The question is, should this library do that that or should it be done by whoever is calling this library?
Might not be simple to solve it in this library, do we pad left or right? What character do we pad with? Some hard coded options is unlikely to satisfy all use-cases.

For the moment I'm going to fix this in my fixgateway plugin but that will only fix it for my specific use-case.
This issue will still be waiting to bite the next person who wants to send strings via CAN.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions