Page 1 of 1

Question about Pi serial numbers

Posted: Tue Sep 04, 2018 4:47 pm
by thagrol
Anyone know if Pi serial numbers are case sensitive?

For a project I'm working on I need to compare two serial numbers but I have no idea whether letter case is important. I'm inclined to go with no as they look like a text representation of hex digits but could someone on the inside confirm (or deny) this please.

Re: Question about Pi serial numbers

Posted: Tue Sep 04, 2018 5:35 pm
by W. H. Heydt
The serial number is a random 32-bit number. If you're seeing what looks like text, then it's probably being shown in hexadecimal. If some of your data is in lower- or mixed-case and you want to get reliable comparison, then do a bit-wise logical OR against spaces and then all the alpha characters will be upper case. FYI...this works in both ASCII and EBCDIC.

Re: Question about Pi serial numbers

Posted: Tue Sep 04, 2018 5:40 pm
by DougieLawson
Hex numbers are not usually case sensitive. Convert it to an unsigned integer compare then convert back.

Re: Question about Pi serial numbers

Posted: Tue Sep 04, 2018 5:59 pm
by thagrol
Thanks guys, you've confirmed what I was thinking.

Re: Question about Pi serial numbers

Posted: Wed Sep 05, 2018 7:19 am
by Paul Webster
Converting to integer and comparing will also remove any potential issue with leading zeroes being present or not - i.e. not only a potential case issue.

Re: Question about Pi serial numbers

Posted: Wed Sep 05, 2018 12:48 pm
by thagrol
Yeah, that's what I went with.

If anyone's interested the relevent project is here: https://github.com/thagrol/usb-gadget