Skip to content

Commit

Permalink
Merge pull request #4 from RV-Argonaut/40-fix-mid0002-parser-missing-…
Browse files Browse the repository at this point in the history
…keys

Fix MID 0002 Implementation
  • Loading branch information
ferm10n authored Mar 28, 2023
2 parents 18b7655 + 6c64d0f commit 3a5c96e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/mid/0002.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ function parser(msg, opts, cb) {
processParser(msg, buffer, "sequenceNumberSupport", "number", 1, position, cb) &&
processKey(msg, buffer, "linkingHandlingSupport", 13, 2, position, cb) &&
processParser(msg, buffer, "linkingHandlingSupport", "number", 1, position, cb) &&
processKey(msg, buffer, "stationID", 14, 2, position, cb) &&
processParser(msg, buffer, "stationID", "number", 10, position, cb) &&
processKey(msg, buffer, "stationName", 15, 2, position, cb) &&
processParser(msg, buffer, "stationName", "string", 25, position, cb) &&
processKey(msg, buffer, "clientID", 16, 2, position, cb) &&
processParser(msg, buffer, "clientID", "number", 1, position, cb) &&
cb(null, msg);
break;

Expand Down Expand Up @@ -192,7 +198,7 @@ function serializer(msg, opts, cb) {
serializerKey(msg, buf, 16, 2, position, cb) &&
serializerField(msg, buf, "stationName", "string", 25, position, cb) &&
serializerKey(msg, buf, 15, 2, position, cb) &&
serializerField(msg, buf, "stationID", "string", 10, position, cb) &&
serializerField(msg, buf, "stationID", "number", 10, position, cb) &&
serializerKey(msg, buf, 14, 2, position, cb) &&
serializerField(msg, buf, "linkingHandlingSupport", "number", 1, position, cb) &&
serializerKey(msg, buf, 13, 2, position, cb) &&
Expand Down
11 changes: 7 additions & 4 deletions test/0002.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ describe("MID 0002", () => {
let msg = {
mid: 2,
revision: 6,
payload: Buffer.from("010001020103Teste Airbag 04ABC05AAAAAAAAAAAAAAAAAAA06BBBBBBBBBBBBBBBBBBB07CCCCCCCCCCCCCCCCCCC08AS254DFCVFDCVGTREDFGHJKL09123987ASD61000311002120131")
payload: Buffer.from("010001020103Teste Airbag 04ABC05AAAAAAAAAAAAAAAAAAA06BBBBBBBBBBBBBBBBBBB07CCCCCCCCCCCCCCCCCCC08AS254DFCVFDCVGTREDFGHJKL09123987ASD6100031100212013114429496729515QASWWEDXCVFR562 DERF34EDF169")
};

MID.parser(msg, {}, (err, data) => {
Expand All @@ -201,7 +201,10 @@ describe("MID 0002", () => {
systemType: 3,
systemSubtype: 2,
sequenceNumberSupport: 0,
linkingHandlingSupport: 1
linkingHandlingSupport: 1,
stationID: 4294967295,
stationName: "QASWWEDXCVFR562 DERF34EDF",
clientID: 9,
}
});

Expand Down Expand Up @@ -389,7 +392,7 @@ describe("MID 0002", () => {
systemSubtype: 2,
sequenceNumberSupport: 0,
linkingHandlingSupport: 1,
stationID: "AESDR56RDT",
stationID: 4294967295,
stationName: "QASWWEDXCVFR562 DERF34EDF",
clientID: 9
}
Expand All @@ -404,7 +407,7 @@ describe("MID 0002", () => {
expect(data).to.be.deep.equal({
mid: 2,
revision: 6,
payload: Buffer.from("010001020103Teste Airbag 04ABC05AAAAAAAAAAAAAAAAAAA06BBBBBBBBBBBBBBBBBBB07CCCCCCCCCCCCCCCCCCC08AS254DFCVFDCVGTREDFGHJKL09123987ASD6100031100212013114AESDR56RDT15QASWWEDXCVFR562 DERF34EDF169")
payload: Buffer.from("010001020103Teste Airbag 04ABC05AAAAAAAAAAAAAAAAAAA06BBBBBBBBBBBBBBBBBBB07CCCCCCCCCCCCCCCCCCC08AS254DFCVFDCVGTREDFGHJKL09123987ASD6100031100212013114429496729515QASWWEDXCVFR562 DERF34EDF169")
});

done();
Expand Down
2 changes: 1 addition & 1 deletion test/sessionControlClient.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ describe("Session Control Client", () => {

switch (step) {
case 0:
stream.push(Buffer.from("01790002006 0000010000020003PA160LDA2 04ACT052.2 0610.15.6 07 08Silver (Ag) 09D240003 1000111001121130\u0000"));
stream.push(Buffer.from("02210002006 0000010000020003PA160LDA2 04ACT052.2 0610.15.6 07 08Silver (Ag) 09D240003 100011100112113014429496729515QASWWEDXCVFR562 DERF34EDF169\u0000"));
step += 1;
break;

Expand Down

0 comments on commit 3a5c96e

Please sign in to comment.