Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MID 0002 revision 6 implementation #41

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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