cantools.database.errors.Error: Standard frame id is more than 11 bits - python-3.x

I used cantools python package to decode canbus message. I used a dbc file created by me for testing. I copied a sample file. When I use can id like 419358976, I get error. But for smaller can ids like 350, it works. Does cantools fail for extended frame ids? how do I get this working?
my code which is failing for extended id's is as follows:
db = cantools.database.load_file('.\\src\\test\\resources\\j1939.dbc')
print(db.decode_message(419358976,b'\xff\xff\xff\xc0\x0c\xff\xff\xff'))
error: cantools.database.errors.Error: Standard frame id 0x18fee900 is more than 11 bits in message EEC1.

I found the answer for my question. The can id like 419358976 is an extended id. So to map that id to the id in the dbc file, I need to add another 32 bit hex number 8000 0000 to the hex can id. Then convert that result hex number to decimal and use it as the id field in the dbc file. It works perfectly after. The above error message is gone after

Related

How to read zip file header manually

I have a file in which i have very important java project source code that got lost.
It is an elf-file. When i open it with and editor most of it is unreadable but the complete java project seems to be embedded as a uncompressed zip folder inside the file with folderstructure and everything (dont ask me why. I only try to get the information back i am not responsible).
The relevant information pieces in the elf-file look like the following:
PK
Üi‰L§½kQ Q 9 file/path/i/cant/show/contenttext
content
content
Because i dont know where the zip folder starts and where it ends and because everything is uncompressed my idea was to write a small script to scrape the from the elf-file and create the complete javaproject from that.
For that i want the file name length from the header so its easy to know where filename ends end filecontent starts.
ThisPK Üi‰L§½kQ Q 9 seems to be the file header of the zipfile. I converted it to hex and it looks like this: 504B03040A2020082020DC69894CA71E BD6B512020205120202039202020
I tried to format that with the info from wikipedia:
504B0304 //sig (this showed me i did something right)
0A20 // version
2008 // generalpurpose flag
2020 // compression method
DC69 // File last modification time
894C // File last modification date
A71EBD6B //CRC-32 of uncompressed data
51202020 //Compressed size (or 0xffffffff for ZIP64)
51202020 //Uncompressed size (or 0xffffffff for ZIP64)
3920 //File name length (n)
2020 //Extra field length (m)
And Endian switch:
04034B50 //sig
200A // version
0820 // generalpurpose flag
2020 // compression method
69DC // File last modification time
4C89 // File last modification date
6BBD1EA7 //CRC-32 of uncompressed data
20202051 //Compressed size (or 0xffffffff for ZIP64)
20202051 //Uncompressed size (or 0xffffffff for ZIP64)
2039 //File name length (n)
2020 //Extra field length (m)
But something seems wrong. The length of the file header is right (30 bytes plus filename) and the numbers seem to have information at the right point but 2020 should be 0000 for compression. To me it seems the conversion to hex is only half right.
What do i have to change to get the right numbers?
I found my error.
The problem of the weird 2020 instead of 0000 was my mistake. I opened the file in notepadd++ copied interesting sections into a new file and converted them there into hex. I think the copying changed the data. When i open the file directly in a hexeditor the zipefile header is all right.

ZPL: RFID, Combining Field Data (^FD) and Field Numbers (^FN)

I am attempting to encode the EPC of a GS1 RFID using ZPL statements on a Zebra 410R printer.
First, consider the following ZPL :
^FD51,0,6,111111,2,33,444^FS
What I am attempting to do, is replace the 444 with a value stored in a field number (^FN).
^XA
^DFE:RFID^FS
^RB96,8,3,3,20,24,10,28
^RFW,E
^FD51,0,6,111111,2,33,^FN11"Enter Barcode"^FS
^XZ
So, How do I replace the '444' portion of the field data with the value stored in the field number (^FN11) ?
Thank you in advance.
Well, maybe a little bit too late, but to anyone, who may have the same question - DF is a pair command, you need to pair it with XF. DF is Download format - here you use the varible ( FD, FN). XF is Recall Format - here you declare the variables.
So, your code just miss the definition of variable, here is the whole code:
Your code:
^XA
^DFR:RFID^FS
^RB96,8,3,3,20,24,10,28
^RFW,E
^FD51,0,6,111111,2,33,^FN11"Enter Barcode"^FS
^XZ
^XA
^XFR:RFID
^FN11^FN444^FS
^XZ

How to generate a pin code in Symfony

I'm working right now on a symfony2 web app and I need to generate automatically and randomly pin-code composed by 6 alphanumeric characters example:
14gkf8
kfgh88
this code will be sent by mail to the use, that's how he will connect to the platform.
anyone have an idea how to make it or there is maybe a ready tool to do it ? thank you
You can generate random codes with the following code:
substr(bin2hex(openssl_random_pseudo_bytes(100)), 0, 6)
Online demo.
openssl_random_pseudo_bytes() will generate random binary data, bin2hex() will transform this binary data as hexadecimal data (e.g. 5c3aa…e55) and substr(…, 0, 6) will keep only the 6 first characters. Since hexadecimal uses values from 0 to 9 and a to f, there is 16 different characters available at each position, so it gives 16^6 = 16,777,216 possibilities (with 0 to 9 and a to z it's 36^6 = 2,176,782,336, only ± 130 times more). If the user doesn't need to type the key, you can use more characters, for example with 12 characters you have many more possibilities: 16^12 = 2,814×10¹⁴.
You can use uniqid() to generate a unique alphanumeric string

Replacing WAV header

So here is what I've got:
The problem that I face requires me to take a specialized header from WAV1 , and put it as the header for WAV2, in order to make WAV2 work with the API that I'm using. However, whenever I try to replace the first 38 characters of WAV2 with the first 38 of WAV1, I get an error when I try to play the file, I get an error saying that it is not formatted properly. Both WAV1 and WAV2 play properly before the edit.
Do you guys have any idea on what I'm doing wrong?
Thanks so much for your help.
-Rhynorater.
Wav format is a standardised format (see https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ for details about file format). I'm not sure what a "specialized" header is (perhaps you could clarify what your specialised header is?) as the format is standard - any variation would not be a wav file.
The first 38 bytes of a wav file are the header and should adhere to the standard. You cannot copy the header from one file and use it for another as the header contains information specific to the individual file (number of channels, sample rate, file length, etc).
If you both files playback normally (how are you testing this?) I'm not sure why the API you are using is not compatible (which API are you using?).

Identify encoding to convert between known strings

I have some ISO 11785 RFID animal tags which are programmed with a number and also have a number written on them. The two numbers are matched through a text file which was sent with the RFID tags. The problem is that the numbers returned by the RFID reader don't match the numbers in the file. I would like someone to help me determine how the tag numbers have been converted to be put in the file. The RFID tag returns a number with manufacturer code followed by a unique animal code.
Here is a sample of the data:
RFID Tag | RFID Response From Tag
8000F580076C2BA9 | 982 000124529577
8000F580076C2C34 | 982 000124529716
8000F580076C2C32 | 982 000124529714
8000F580076C2DD4 | 982 000124530132
8000F580076C2BDC | 982 000124529628
Can anyone suggest what I should do to the number on the left to get to the number on the right? I have tried converting from hex to decimal but that doesn't seem to work.
Edit
It turns out if I take the last 7 characters of hex then they become the animal ID, the F58 translates to the 3982 which can be worked around to get me the 982 part. I think I should be able to work from this but thought I would leave the post anyway in case someone else has the same problem.
The field encoding is defined by the ISO standard.
bits
1 Animal flag
2-4 retag counter
5-9 user information
10-15 reserved
16 additional data flag
17-26 country/manufacturer code (982 is Allflex)
27-64 unique ID

Resources