Fetched list of manufacturers from dlms.com

pull/22/head
weetmuts 2019-04-01 23:22:09 +02:00
rodzic 4d4635a576
commit bf5941ef42
5 zmienionych plików z 3432 dodań i 174 usunięć

1156
DLMS_Flagids.csv 100644

Plik diff jest za duży Load Diff

Wyświetl plik

@ -126,42 +126,65 @@ testd:
./build_debug/testinternals
./test.sh build_debug/wmbusmeters
update_manufacturers:
wget http://www.m-bus.de/man.html
echo '// Data downloaded from http://www.m-bus.de/man.html' > m.h
echo -n '// ' >> m.h
date --rfc-3339=date >> m.h
echo >> m.h
echo '#ifndef MANUFACTURERS_H' >> m.h
iconv -f utf-8 -t ascii//TRANSLIT -c DLMS_Flagids.csv -o tmp.flags
cat tmp.flags | grep -v ^# | cut -f 1 > list.flags
cat tmp.flags | grep -v ^# | cut -f 2 > names.flags
cat tmp.flags | grep -v ^# | cut -f 3 > countries.flags
cat countries.flags | sort -u | grep -v '^$$' > uniquec.flags
cat names.flags | tr -d "'" | tr -c 'a-zA-Z0-9\n' ' ' | tr -s ' ' | sed 's/^ //g' | sed 's/ $$//g' > ansi.flags
cat ansi.flags | sed 's/\(^.......[^0123456789]*\)[0123456789]\+.*/\1/g' > cleaned.flags
cat cleaned.flags | sed -e "$$(sed 's:.*:s/&//Ig:' uniquec.flags)" > cleanedc.flags
cat cleanedc.flags | sed \
-e 's/ ab\( \|$$\)/ /Ig' \
-e 's/ ag\( \|$$\)/ /Ig' \
-e 's/ a \?s\( \|$$\)/ /Ig' \
-e 's/ co\( \|$$\)/ /Ig' \
-e 's/ b \?v\( \|$$\)/ /Ig' \
-e 's/ bvba\( \|$$\)/ /Ig' \
-e 's/ corp\( \|$$\)/ /Ig' \
-e 's/ d \?o \?o\( \|$$\)/ /g' \
-e 's/ d \?d\( \|$$\)/ /g' \
-e 's/ gmbh//Ig' \
-e 's/ gbr//Ig' \
-e 's/ inc\( \|$$\)/ /Ig' \
-e 's/ kg\( \|$$\)/ /Ig' \
-e 's/ llc/ /Ig' \
-e 's/ ltd//Ig' \
-e 's/ limited//Ig' \
-e 's/ nv\( \|$$\)/ /Ig' \
-e 's/ oy//Ig' \
-e 's/ ood\( \|$$\)/ /Ig' \
-e 's/ooo\( \|$$\)/ /Ig' \
-e 's/ pvt\( \|$$\)/ /Ig' \
-e 's/ pte\( \|$$\)/ /Ig' \
-e 's/ pty\( \|$$\)/ /Ig' \
-e 's/ plc\( \|$$\)/ /Ig' \
-e 's/ private\( \|$$\)/ /Ig' \
-e 's/ s \?a\( \|$$\)/ /Ig' \
-e 's/ sarl\( \|$$\)/ /Ig' \
-e 's/ sagl\( \|$$\)/ /Ig' \
-e 's/ s c ul//Ig' \
-e 's/ s \?l\( \|$$\)/ /Ig' \
-e 's/ s \?p \?a\( \|$$\)/ /Ig' \
-e 's/ sp j\( \|$$\)/ /Ig' \
-e 's/ sp z o o//Ig' \
-e 's/ s r o//Ig' \
-e 's/ s \?r \?l//Ig' \
-e 's/ ug\( \|$$\)/ /Ig' \
> trimmed.flags
cat trimmed.flags | tr -s ' ' | sed 's/^ //g' | sed 's/ $$//g' > done.flags
paste -d '|,' list.flags done.flags countries.flags | sed 's/,/, /g' | sed 's/ |/|/g' > manufacturers.txt
echo '#ifndef MANUFACTURERS_H' > m.h
echo '#define MANUFACTURERS_H' >> m.h
echo '#define MANFCODE(a,b,c) ((a-64)*1024+(b-64)*32+(c-64))' >> m.h
echo '#define LIST_OF_MANUFACTURERS \' >> m.h
cat man.html | tr -d '\r\n' | sed \
-e 's/.*<table>//' \
-e 's/<\/table>.*//' \
-e 's/<tr>/X(/g' \
-e 's/<script[^<]*<\/script>//g' \
-e 's/<a href=[^>]*>//g' \
-e 's/<\/a>//g' \
-e 's/<a name[^>]*>//g' \
-e 's/<td>/\t/g' \
-e 's/<\/td>//g' \
-e 's/&auml;/ä/g' \
-e 's/&uuml;/ü/g' \
-e 's/&ouml;/ö/g' \
-e 's/,/ /g' \
-e 's/<\/tr>/)\\\n/g' | \
grep -v '<caption>' | tr -s ' ' | tr -s '\t' | tr '\t' '|' > tmpfile
echo 'X(|QDS|QUNDIS GmbH)\' >> tmpfile
echo 'X(|APA|Apator Powogaz S.A)\' >> tmpfile
cat tmpfile | sed -e "s/X(|\(.\)\(.\)\(.\)/X(\1\2\3|MANFCODE('\1','\2','\3')|/g" | \
tr -s '|' ',' >> m.h
echo "#define LIST_OF_MANUFACTURERS \\" >> m.h
cat manufacturers.txt | sed -e "s/\(.\)\(.\)\(.\).\(.*\)/X(\1\2\3,MANFCODE('\1','\2','\3'),\"\4\")\\\\/g" >> m.h
echo >> m.h
cat tmpfile | sed -e "s/X(|\(.\)\(.\)\(.\).*/#define MANUFACTURER_\1\2\3 MANFCODE('\1','\2','\3')/g" \
>> m.h
cat manufacturers.txt | sed -e "s/\(.\)\(.\)\(.\).*/#define MANUFACTURER_\1\2\3 MANFCODE('\1','\2','\3')/g" >> m.h
echo >> m.h
echo '#endif' >> m.h
rm tmpfile
mv m.h src/manufacturers.h
build_fuzz:

Plik diff jest za duży Load Diff

Wyświetl plik

@ -46,29 +46,29 @@ LinkMode isLinkMode(const char *arg)
}
struct Manufacturer {
char code[4];
const char *code;
int m_field;
char name[64];
const char *name;
Manufacturer(const char *c, int m, const char *n) {
code = c;
m_field = m;
name = n;
}
};
Manufacturer manufacturers[] = {
#define X(key,code,name) {#key,code,#name},
LIST_OF_MANUFACTURERS
#undef X
{"",0,""}
};
vector<Manufacturer> manufacturers_;
struct Initializer { Initializer(); };
static Initializer initializser_;
Initializer::Initializer() {
for (auto &m : manufacturers) {
m.m_field = \
(m.code[0]-64)*1024 +
(m.code[1]-64)*32 +
(m.code[2]-64);
}
#define X(key,code,name) manufacturers_.push_back(Manufacturer(#key,code,name));
LIST_OF_MANUFACTURERS
#undef X
}
void Telegram::print() {
@ -121,7 +121,7 @@ void Telegram::verboseFields() {
}
string manufacturer(int m_field) {
for (auto &m : manufacturers) {
for (auto &m : manufacturers_) {
if (m.m_field == m_field) return m.name;
}
return "Unknown";

Wyświetl plik

@ -18,22 +18,22 @@ EXPECTED=$(cat <<EOF
No meters configured. Printing id:s of all telegrams heard!
Received telegram from: 12345678
manufacturer: (SON) Sontex SA
manufacturer: (SON) Sontex, Switzerland
device type: Warm Water (30°C-90°C) meter
Received telegram from: 11111111
manufacturer: (SON) Sontex SA
manufacturer: (SON) Sontex, Switzerland
device type: Water meter
Received telegram from: 12345699
manufacturer: (SEN) Sensus GmbH
manufacturer: (SEN) Sensus Metering Systems, Germany
device type: Water meter
Received telegram from: 33225544
manufacturer: (SEN) Sensus GmbH
manufacturer: (SEN) Sensus Metering Systems, Germany
device type: Water meter
Received telegram from: 20202020
manufacturer: (APA) Apator Powogaz S.A
manufacturer: (APA) Apator, Poland
device type: Water meter
Received telegram from: 10101010
manufacturer: (APA) Apator Powogaz S.A
manufacturer: (APA) Apator, Poland
device type: Electricity meter
EOF
)