This commit is contained in:
Joel Wetzell
2026-07-13 14:09:21 -05:00
parent 4bb1e87e03
commit 466228fb4a
62 changed files with 2157 additions and 1851 deletions
+2 -1
View File
@@ -20,7 +20,8 @@
},
"javascript": {
"formatter": {
"quoteStyle": "double"
"quoteStyle": "single",
"trailingCommas": "es5"
}
},
"assist": {
+9 -6
View File
@@ -3,14 +3,17 @@ const { Decoder } = require('../dist/cjs');
const decoder = new Decoder();
const infoPacketBuffer = new Uint8Array([
0x56, 0x67, 0x34, 0x80, 0x00, 0x00, 0x0c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x01,
0x01, 0x01, 0x00, 0x0b, 0x00, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x20, 0x4e, 0x61, 0x6d, 0x65, 0x02, 0x00, 0x11,
0x80, 0x01, 0x00, 0x0d, 0x80, 0x00, 0x00, 0x09, 0x00, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x65, 0x72, 0x20, 0x31,
0x56, 0x67, 0x34, 0x80, 0x00, 0x00, 0x0c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x02, 0x03, 0x01, 0x01, 0x01, 0x00, 0x0b, 0x00, 0x53, 0x65,
0x72, 0x76, 0x65, 0x72, 0x20, 0x4e, 0x61, 0x6d, 0x65, 0x02, 0x00, 0x11, 0x80,
0x01, 0x00, 0x0d, 0x80, 0x00, 0x00, 0x09, 0x00, 0x54, 0x72, 0x61, 0x63, 0x6b,
0x65, 0x72, 0x20, 0x31,
]);
const dataPacketBuffer = new Uint8Array([
0x55, 0x67, 0x28, 0x80, 0x00, 0x00, 0x0c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x01,
0x01, 0x01, 0x00, 0x14, 0x80, 0x01, 0x00, 0x10, 0x80, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00,
0x80, 0x3f, 0x00, 0x00, 0x80, 0x3f,
0x55, 0x67, 0x28, 0x80, 0x00, 0x00, 0x0c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x02, 0x03, 0x01, 0x01, 0x01, 0x00, 0x14, 0x80, 0x01, 0x00,
0x10, 0x80, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80,
0x3f, 0x00, 0x00, 0x80, 0x3f,
]);
decoder.decode(infoPacketBuffer);
+15 -5
View File
@@ -26,15 +26,21 @@ setInterval(() => {
const trackerName = decoder.trackers[trackerId]?.name;
console.log(`Tracker - id: ${trackerId} | name: ${trackerName || ''}`);
if (tracker.pos) {
console.log(`\tpos: ${tracker.pos.x}, ${tracker.pos.x}, ${tracker.pos.x}`);
console.log(
`\tpos: ${tracker.pos.x}, ${tracker.pos.x}, ${tracker.pos.x}`
);
}
if (tracker.speed) {
console.log(`\tspeed: ${tracker.speed.x}, ${tracker.speed.y}, ${tracker.speed.z}`);
console.log(
`\tspeed: ${tracker.speed.x}, ${tracker.speed.y}, ${tracker.speed.z}`
);
}
if (tracker.ori) {
console.log(`\tori: ${tracker.ori.x}, ${tracker.ori.y}, ${tracker.ori.z}`);
console.log(
`\tori: ${tracker.ori.x}, ${tracker.ori.y}, ${tracker.ori.z}`
);
}
if (tracker.status) {
@@ -42,11 +48,15 @@ setInterval(() => {
}
if (tracker.accel) {
console.log(`\taccel: ${tracker.accel.x}, ${tracker.accel.y}, ${tracker.accel.z}`);
console.log(
`\taccel: ${tracker.accel.x}, ${tracker.accel.y}, ${tracker.accel.z}`
);
}
if (tracker.trgtpos) {
console.log(`\ttrgtpos: ${tracker.trgtpos.x}, ${tracker.trgtpos.y}, ${tracker.trgtpos.z}`);
console.log(
`\ttrgtpos: ${tracker.trgtpos.x}, ${tracker.trgtpos.y}, ${tracker.trgtpos.z}`
);
}
if (tracker.timestamp) {
+3 -1
View File
@@ -19,7 +19,9 @@ trackers.push(new Tracker(8, 'Neptune'));
trackers.push(new Tracker(9, 'Pluto'));
const orbits = [1.0, 88.0, 224.7, 365.2, 687, 4332, 10760, 30700, 60200, 90600];
const distFromSun = [0, 0.58, 1.08, 1.5, 2.28, 7.78, 14.29, 28.71, 45.04, 59.13];
const distFromSun = [
0, 0.58, 1.08, 1.5, 2.28, 7.78, 14.29, 28.71, 45.04, 59.13,
];
let timestamp = 0;
setInterval(() => {
+24 -10
View File
@@ -77,16 +77,23 @@ export class Decoder {
throw new Error('malformed packet');
}
if (currentInfoPacketHeader.data.frameId) {
if (this.infoPacketFrames[currentInfoPacketHeader.data.frameId] === undefined) {
if (
this.infoPacketFrames[currentInfoPacketHeader.data.frameId] ===
undefined
) {
this.infoPacketFrames[currentInfoPacketHeader.data.frameId] = [];
}
this.infoPacketFrames[currentInfoPacketHeader.data.frameId].push(infoPacket);
this.infoPacketFrames[currentInfoPacketHeader.data.frameId].push(
infoPacket
);
if (
this.infoPacketFrames[currentInfoPacketHeader.data.frameId].length ===
currentInfoPacketHeader.data.framePacketCount
this.infoPacketFrames[currentInfoPacketHeader.data.frameId]
.length === currentInfoPacketHeader.data.framePacketCount
) {
this.updateInfo(this.infoPacketFrames[currentInfoPacketHeader.data.frameId]);
this.updateInfo(
this.infoPacketFrames[currentInfoPacketHeader.data.frameId]
);
delete this.infoPacketFrames[currentInfoPacketHeader.data.frameId];
}
}
@@ -101,15 +108,22 @@ export class Decoder {
}
if (currentDataPacketHeader.data.frameId) {
if (this.dataPacketFrames[currentDataPacketHeader.data.frameId] === undefined) {
if (
this.dataPacketFrames[currentDataPacketHeader.data.frameId] ===
undefined
) {
this.dataPacketFrames[currentDataPacketHeader.data.frameId] = [];
}
this.dataPacketFrames[currentDataPacketHeader.data.frameId].push(dataPacket);
this.dataPacketFrames[currentDataPacketHeader.data.frameId].push(
dataPacket
);
if (
this.dataPacketFrames[currentDataPacketHeader.data.frameId].length ===
currentDataPacketHeader.data.framePacketCount
this.dataPacketFrames[currentDataPacketHeader.data.frameId]
.length === currentDataPacketHeader.data.framePacketCount
) {
this.updateData(this.dataPacketFrames[currentDataPacketHeader.data.frameId]);
this.updateData(
this.dataPacketFrames[currentDataPacketHeader.data.frameId]
);
delete this.dataPacketFrames[currentDataPacketHeader.data.frameId];
}
}
+3 -1
View File
@@ -10,7 +10,9 @@ export default (buffer: Uint8Array): Chunk => {
// NOTE(jwetzell): this data is split up as 1 bit for hasSubchunks and 15 bits for the dataLen
const combinedLengthAndFlag = (buffer[3] << 8) + buffer[2];
const hasSubchunks = combinedLengthAndFlag > 32768;
const dataLen = hasSubchunks ? combinedLengthAndFlag - 32768 : combinedLengthAndFlag;
const dataLen = hasSubchunks
? combinedLengthAndFlag - 32768
: combinedLengthAndFlag;
const header = {
id,
+13 -4
View File
@@ -1,5 +1,8 @@
import { Constants } from '../../constants.js';
import type { DataPacketChunk, DataPacketChunkData } from '../../models/data/data-packet-chunk.js';
import type {
DataPacketChunk,
DataPacketChunkData,
} from '../../models/data/data-packet-chunk.js';
import { Decoders } from '../index.js';
export default (buffer: Uint8Array): DataPacketChunk => {
@@ -10,17 +13,23 @@ export default (buffer: Uint8Array): DataPacketChunk => {
if (chunk.header.hasSubchunks && chunk.chunkData && chunk.header.dataLen) {
let offset = 0;
while (offset < chunk.header.dataLen) {
const chunkId = (chunk.chunkData.subarray(offset)[1] << 8) + chunk.chunkData.subarray(offset)[0];
const chunkId =
(chunk.chunkData.subarray(offset)[1] << 8) +
chunk.chunkData.subarray(offset)[0];
switch (chunkId) {
case 0x0000:
data.packetHeader = Decoders.PacketHeaderChunk(chunk.chunkData.subarray(offset));
data.packetHeader = Decoders.PacketHeaderChunk(
chunk.chunkData.subarray(offset)
);
offset += Constants.CHUNK_HEADER_SIZE;
if (data.packetHeader.chunk.header.dataLen) {
offset += data.packetHeader.chunk.header.dataLen;
}
break;
case 0x0001:
data.trackerList = Decoders.DataTrackerListChunk(chunk.chunkData.subarray(offset));
data.trackerList = Decoders.DataTrackerListChunk(
chunk.chunkData.subarray(offset)
);
offset += Constants.CHUNK_HEADER_SIZE;
if (data.trackerList.chunk.header.dataLen) {
offset += data.trackerList.chunk.header.dataLen;
+28 -9
View File
@@ -1,5 +1,8 @@
import { Constants } from '../../constants.js';
import type { DataTrackerChunk, DataTrackerChunkData } from '../../models/data/data-tracker-chunk.js';
import type {
DataTrackerChunk,
DataTrackerChunkData,
} from '../../models/data/data-tracker-chunk.js';
import { Decoders } from '../index.js';
export default (buffer: Uint8Array): DataTrackerChunk => {
@@ -8,28 +11,44 @@ export default (buffer: Uint8Array): DataTrackerChunk => {
if (chunk.chunkData && chunk.header.dataLen) {
let offset = 0;
while (offset < chunk.header.dataLen) {
const trackerFieldChunk = Decoders.Chunk(chunk.chunkData.subarray(offset));
const trackerFieldChunk = Decoders.Chunk(
chunk.chunkData.subarray(offset)
);
switch (trackerFieldChunk.header.id) {
case 0x0000:
data.pos = Decoders.DataTrackerXYZChunk(chunk.chunkData.subarray(offset));
data.pos = Decoders.DataTrackerXYZChunk(
chunk.chunkData.subarray(offset)
);
break;
case 0x0001:
data.speed = Decoders.DataTrackerXYZChunk(chunk.chunkData.subarray(offset));
data.speed = Decoders.DataTrackerXYZChunk(
chunk.chunkData.subarray(offset)
);
break;
case 0x0002:
data.ori = Decoders.DataTrackerXYZChunk(chunk.chunkData.subarray(offset));
data.ori = Decoders.DataTrackerXYZChunk(
chunk.chunkData.subarray(offset)
);
break;
case 0x0003:
data.status = Decoders.DataTrackerStatusChunk(chunk.chunkData.subarray(offset));
data.status = Decoders.DataTrackerStatusChunk(
chunk.chunkData.subarray(offset)
);
break;
case 0x0004:
data.accel = Decoders.DataTrackerXYZChunk(chunk.chunkData.subarray(offset));
data.accel = Decoders.DataTrackerXYZChunk(
chunk.chunkData.subarray(offset)
);
break;
case 0x0005:
data.trgtpos = Decoders.DataTrackerXYZChunk(chunk.chunkData.subarray(offset));
data.trgtpos = Decoders.DataTrackerXYZChunk(
chunk.chunkData.subarray(offset)
);
break;
case 0x0006:
data.timestamp = Decoders.DataTrackerTimestampChunk(chunk.chunkData.subarray(offset));
data.timestamp = Decoders.DataTrackerTimestampChunk(
chunk.chunkData.subarray(offset)
);
break;
default:
break;
+7 -2
View File
@@ -1,5 +1,8 @@
import { Constants } from '../../constants.js';
import type { DataTrackerListChunk, DataTrackerListChunkData } from '../../models/data/data-tracker-list-chunk.js';
import type {
DataTrackerListChunk,
DataTrackerListChunkData,
} from '../../models/data/data-tracker-list-chunk.js';
import type { DataTrackerChunk } from '../../models/index.js';
import { Decoders } from '../index.js';
@@ -11,7 +14,9 @@ export default (buffer: Uint8Array): DataTrackerListChunk => {
if (chunk.chunkData) {
let offset = 0;
while (offset < chunk.chunkData.length) {
const trackerChunk = Decoders.DataTrackerChunk(chunk.chunkData.subarray(offset));
const trackerChunk = Decoders.DataTrackerChunk(
chunk.chunkData.subarray(offset)
);
offset += Constants.CHUNK_HEADER_SIZE;
if (trackerChunk.chunk.header.dataLen) {
offset += trackerChunk.chunk.header.dataLen;
@@ -7,7 +7,11 @@ import { Decoders } from '../index.js';
export default (buffer: Uint8Array): DataTrackerStatusChunk => {
const chunk = Decoders.Chunk(buffer);
const view = new DataView(chunk.chunkData.buffer, chunk.chunkData.byteOffset, chunk.chunkData.byteLength);
const view = new DataView(
chunk.chunkData.buffer,
chunk.chunkData.byteOffset,
chunk.chunkData.byteLength
);
const validity = view.getFloat32(0, true);
const data: DataTrackerStatusChunkData = {
@@ -7,7 +7,11 @@ import { Decoders } from '../index.js';
export default (buffer: Uint8Array): DataTrackerTimestampChunk => {
const chunk = Decoders.Chunk(buffer);
const view = new DataView(chunk.chunkData.buffer, chunk.chunkData.byteOffset, chunk.chunkData.byteLength);
const view = new DataView(
chunk.chunkData.buffer,
chunk.chunkData.byteOffset,
chunk.chunkData.byteLength
);
const timestamp = view.getBigUint64(0, true);
const data: DataTrackerTimestampChunkData = {
+9 -2
View File
@@ -1,11 +1,18 @@
import type { DataTrackerXYZChunk, DataTrackerXYZChunkData } from '../../models/data/data-tracker-xyz-chunk.js';
import type {
DataTrackerXYZChunk,
DataTrackerXYZChunkData,
} from '../../models/data/data-tracker-xyz-chunk.js';
import { Decoders } from '../index.js';
export default (buffer: Uint8Array): DataTrackerXYZChunk => {
const chunk = Decoders.Chunk(buffer);
// TODO(jwetzell): add error handling
const view = new DataView(chunk.chunkData.buffer, chunk.chunkData.byteOffset, chunk.chunkData.byteLength);
const view = new DataView(
chunk.chunkData.buffer,
chunk.chunkData.byteOffset,
chunk.chunkData.byteLength
);
const data: DataTrackerXYZChunkData = {
x: view.getFloat32(0, true),
+16 -5
View File
@@ -1,5 +1,8 @@
import { Constants } from '../../constants.js';
import type { InfoPacketChunk, InfoPacketChunkData } from '../../models/info/info-packet-chunk.js';
import type {
InfoPacketChunk,
InfoPacketChunkData,
} from '../../models/info/info-packet-chunk.js';
import { Decoders } from '../index.js';
export default (buffer: Uint8Array): InfoPacketChunk => {
@@ -10,24 +13,32 @@ export default (buffer: Uint8Array): InfoPacketChunk => {
if (chunk.header.hasSubchunks && chunk.chunkData && chunk.header.dataLen) {
let offset = 0;
while (offset < chunk.header.dataLen) {
const chunkId = (chunk.chunkData.subarray(offset)[1] << 8) + chunk.chunkData.subarray(offset)[0];
const chunkId =
(chunk.chunkData.subarray(offset)[1] << 8) +
chunk.chunkData.subarray(offset)[0];
switch (chunkId) {
case 0x0000:
data.packetHeader = Decoders.PacketHeaderChunk(chunk.chunkData.subarray(offset));
data.packetHeader = Decoders.PacketHeaderChunk(
chunk.chunkData.subarray(offset)
);
offset += Constants.CHUNK_HEADER_SIZE;
if (data.packetHeader?.chunk.header.dataLen) {
offset += data.packetHeader.chunk.header.dataLen;
}
break;
case 0x0001:
data.systemName = Decoders.InfoSystemNameChunk(chunk.chunkData.subarray(offset));
data.systemName = Decoders.InfoSystemNameChunk(
chunk.chunkData.subarray(offset)
);
offset += Constants.CHUNK_HEADER_SIZE;
if (data.systemName?.chunk.header.dataLen) {
offset += data.systemName?.chunk.header.dataLen;
}
break;
case 0x0002:
data.trackerList = Decoders.InfoTrackerListChunk(chunk.chunkData.subarray(offset));
data.trackerList = Decoders.InfoTrackerListChunk(
chunk.chunkData.subarray(offset)
);
offset += Constants.CHUNK_HEADER_SIZE;
if (data.trackerList?.chunk.header.dataLen) {
offset += data.trackerList.chunk.header.dataLen;
+7 -2
View File
@@ -1,4 +1,7 @@
import type { InfoSystemNameChunk, InfoSystemNameChunkData } from '../../models/info/info-system-name-chunk.js';
import type {
InfoSystemNameChunk,
InfoSystemNameChunkData,
} from '../../models/info/info-system-name-chunk.js';
import { Decoders } from '../index.js';
const nameDecoder = new TextDecoder();
@@ -6,7 +9,9 @@ export default (buffer: Uint8Array): InfoSystemNameChunk => {
const chunk = Decoders.Chunk(buffer);
const data: InfoSystemNameChunkData = {
systemName: nameDecoder.decode(chunk.chunkData.subarray(0, chunk.header.dataLen)),
systemName: nameDecoder.decode(
chunk.chunkData.subarray(0, chunk.header.dataLen)
),
};
return {
+10 -3
View File
@@ -1,5 +1,8 @@
import { Constants } from '../../constants.js';
import type { InfoTrackerChunk, InfoTrackerChunkData } from '../../models/info/info-tracker-chunk.js';
import type {
InfoTrackerChunk,
InfoTrackerChunkData,
} from '../../models/info/info-tracker-chunk.js';
import { Decoders } from '../index.js';
export default (buffer: Uint8Array): InfoTrackerChunk => {
@@ -8,11 +11,15 @@ export default (buffer: Uint8Array): InfoTrackerChunk => {
if (chunk.header.hasSubchunks && chunk.chunkData && chunk.header.dataLen) {
let offset = 0;
while (offset < chunk.header.dataLen) {
const chunkId = (chunk.chunkData.subarray(offset)[1] << 8) + chunk.chunkData.subarray(offset)[0];
const chunkId =
(chunk.chunkData.subarray(offset)[1] << 8) +
chunk.chunkData.subarray(offset)[0];
switch (chunkId) {
case 0x0000: {
const data: InfoTrackerChunkData = {
trackerName: Decoders.InfoTrackerNameChunk(chunk.chunkData.subarray(offset)),
trackerName: Decoders.InfoTrackerNameChunk(
chunk.chunkData.subarray(offset)
),
};
offset += Constants.CHUNK_HEADER_SIZE;
if (data.trackerName.chunk.header.dataLen) {
+7 -2
View File
@@ -1,6 +1,9 @@
import { Constants } from '../../constants.js';
import type { InfoTrackerChunk } from '../../models/info/info-tracker-chunk.js';
import type { InfoTrackerListChunk, InfoTrackerListChunkData } from '../../models/info/info-tracker-list-chunk.js';
import type {
InfoTrackerListChunk,
InfoTrackerListChunkData,
} from '../../models/info/info-tracker-list-chunk.js';
import { Decoders } from '../index.js';
export default (buffer: Uint8Array): InfoTrackerListChunk => {
@@ -12,7 +15,9 @@ export default (buffer: Uint8Array): InfoTrackerListChunk => {
let offset = 0;
if (chunk.header.dataLen) {
while (offset < chunk.header.dataLen) {
const trackerChunk = Decoders.InfoTrackerChunk(chunk.chunkData.subarray(offset));
const trackerChunk = Decoders.InfoTrackerChunk(
chunk.chunkData.subarray(offset)
);
offset += Constants.CHUNK_HEADER_SIZE;
if (trackerChunk.chunk.header.dataLen) {
offset += trackerChunk.chunk.header.dataLen;
+7 -2
View File
@@ -1,4 +1,7 @@
import type { InfoTrackerNameChunk, InfoTrackerNameChunkData } from '../../models/info/info-tracker-name-chunk.js';
import type {
InfoTrackerNameChunk,
InfoTrackerNameChunkData,
} from '../../models/info/info-tracker-name-chunk.js';
import { Decoders } from '../index.js';
const nameDecoder = new TextDecoder();
@@ -6,7 +9,9 @@ export default (buffer: Uint8Array): InfoTrackerNameChunk => {
const chunk = Decoders.Chunk(buffer);
const data: InfoTrackerNameChunkData = {
trackerName: nameDecoder.decode(chunk.chunkData.subarray(0, chunk.header.dataLen)),
trackerName: nameDecoder.decode(
chunk.chunkData.subarray(0, chunk.header.dataLen)
),
};
return {
+4 -1
View File
@@ -1,4 +1,7 @@
import type { PacketHeaderChunk, PacketHeaderChunkData } from '../models/packet-header-chunk.js';
import type {
PacketHeaderChunk,
PacketHeaderChunkData,
} from '../models/packet-header-chunk.js';
import { Decoders } from './index.js';
export default (buffer: Uint8Array): PacketHeaderChunk => {
+33 -8
View File
@@ -7,7 +7,11 @@ export class Encoder {
private versionLow: number;
dataFrameId: number = 1;
infoFrameId: number = 1;
constructor(systemName: string, versionHigh: number = 2, versionLow: number = 3) {
constructor(
systemName: string,
versionHigh: number = 2,
versionLow: number = 3
) {
this.systemName = systemName;
this.versionHigh = versionHigh;
this.versionLow = versionLow;
@@ -45,17 +49,25 @@ export class Encoder {
const systemNameChunk = Encoders.InfoSystemNameChunk(this.systemName);
const trackerChunks = trackers.map((tracker: Tracker) => tracker.getInfoChunk());
const trackerChunks = trackers.map((tracker: Tracker) =>
tracker.getInfoChunk()
);
const infoPackets: Uint8Array[] = [];
const trackerChunksLists: Uint8Array[][] = [];
let currentTrackerList: Uint8Array[] = [];
let currentInfoPacketSize = Constants.PACKET_HEADER_SIZE + systemNameChunk.length + Constants.CHUNK_HEADER_SIZE;
let currentInfoPacketSize =
Constants.PACKET_HEADER_SIZE +
systemNameChunk.length +
Constants.CHUNK_HEADER_SIZE;
trackerChunks.forEach((trackerChunk: Uint8Array) => {
if (currentInfoPacketSize + trackerChunk.length > Constants.MAX_UDP_PACKET_SIZE) {
if (
currentInfoPacketSize + trackerChunk.length >
Constants.MAX_UDP_PACKET_SIZE
) {
trackerChunksLists.push(currentTrackerList);
currentTrackerList = [];
currentInfoPacketSize = 0;
@@ -73,7 +85,11 @@ export class Encoder {
);
trackerChunksLists.forEach((trackerChunkList) => {
infoPackets.push(
Encoders.InfoPacketChunk(header, systemNameChunk, Encoders.InfoTrackerListChunk(trackerChunkList))
Encoders.InfoPacketChunk(
header,
systemNameChunk,
Encoders.InfoTrackerListChunk(trackerChunkList)
)
);
});
this.infoFrameId += 1;
@@ -100,10 +116,14 @@ export class Encoder {
const trackerChunksLists: Uint8Array[][] = [];
let currentTrackerList: Uint8Array[] = [];
let currentDataPacketSize = Constants.PACKET_HEADER_SIZE + Constants.CHUNK_HEADER_SIZE;
let currentDataPacketSize =
Constants.PACKET_HEADER_SIZE + Constants.CHUNK_HEADER_SIZE;
allTrackerChunks.forEach((trackerChunk) => {
if (currentDataPacketSize + trackerChunk.length > Constants.MAX_UDP_PACKET_SIZE) {
if (
currentDataPacketSize + trackerChunk.length >
Constants.MAX_UDP_PACKET_SIZE
) {
trackerChunksLists.push(currentTrackerList);
currentTrackerList = [];
currentDataPacketSize = 0;
@@ -121,7 +141,12 @@ export class Encoder {
trackerChunksLists.length
);
trackerChunksLists.forEach((trackerChunks) => {
dataPackets.push(Encoders.DataPacketChunk(header, Encoders.DataTrackerListChunk(trackerChunks)));
dataPackets.push(
Encoders.DataPacketChunk(
header,
Encoders.DataTrackerListChunk(trackerChunks)
)
);
});
this.dataFrameId += 1;
if (this.dataFrameId > 255) {
+5 -1
View File
@@ -1,5 +1,9 @@
const header = new DataView(new ArrayBuffer(4));
export default (id: number, chunkData: Uint8Array, hasSubchunks: boolean): Uint8Array => {
export default (
id: number,
chunkData: Uint8Array,
hasSubchunks: boolean
): Uint8Array => {
if (!Number.isInteger(id)) {
throw new Error('chunk id must be an integer');
}
+7 -2
View File
@@ -1,6 +1,11 @@
import chunk from '../chunk.js';
export default (packetHeaderChunk: Uint8Array, trackerListChunk: Uint8Array): Uint8Array => {
const chunkData = new Uint8Array(packetHeaderChunk.length + trackerListChunk.length);
export default (
packetHeaderChunk: Uint8Array,
trackerListChunk: Uint8Array
): Uint8Array => {
const chunkData = new Uint8Array(
packetHeaderChunk.length + trackerListChunk.length
);
chunkData.set(packetHeaderChunk);
chunkData.set(trackerListChunk, packetHeaderChunk.length);
return chunk(0x6755, chunkData, true);
+7 -2
View File
@@ -5,10 +5,15 @@ export default (
systemNameChunk: Uint8Array,
trackerListChunk: Uint8Array
): Uint8Array => {
const chunkData = new Uint8Array(packetHeaderChunk.length + systemNameChunk.length + trackerListChunk.length);
const chunkData = new Uint8Array(
packetHeaderChunk.length + systemNameChunk.length + trackerListChunk.length
);
chunkData.set(packetHeaderChunk);
chunkData.set(systemNameChunk, packetHeaderChunk.length);
chunkData.set(trackerListChunk, packetHeaderChunk.length + systemNameChunk.length);
chunkData.set(
trackerListChunk,
packetHeaderChunk.length + systemNameChunk.length
);
return chunk(0x6756, chunkData, true);
};
+2 -1
View File
@@ -1,3 +1,4 @@
import chunk from '../chunk.js';
const nameEncoder = new TextEncoder();
export default (systemName: string): Uint8Array => chunk(0x0001, nameEncoder.encode(systemName), false);
export default (systemName: string): Uint8Array =>
chunk(0x0001, nameEncoder.encode(systemName), false);
+2 -1
View File
@@ -1,4 +1,5 @@
import chunk from '../chunk.js';
const nameEncoder = new TextEncoder();
export default (trackerName: string) => chunk(0x0000, nameEncoder.encode(trackerName), false);
export default (trackerName: string) =>
chunk(0x0000, nameEncoder.encode(trackerName), false);
+23 -6
View File
@@ -126,7 +126,9 @@ export class Tracker {
}
if (this.speed) {
fieldChunks.push(dataTrackerSpeedChunk(this.speed.x, this.speed.y, this.speed.z));
fieldChunks.push(
dataTrackerSpeedChunk(this.speed.x, this.speed.y, this.speed.z)
);
}
if (this.ori) {
@@ -138,11 +140,15 @@ export class Tracker {
}
if (this.accel) {
fieldChunks.push(dataTrackerAccelChunk(this.accel.x, this.accel.y, this.accel.z));
fieldChunks.push(
dataTrackerAccelChunk(this.accel.x, this.accel.y, this.accel.z)
);
}
if (this.trgtpos) {
fieldChunks.push(dataTrackerTrgtposChunk(this.trgtpos.x, this.trgtpos.y, this.trgtpos.z));
fieldChunks.push(
dataTrackerTrgtposChunk(this.trgtpos.x, this.trgtpos.y, this.trgtpos.z)
);
}
if (this.timestamp) {
@@ -164,7 +170,11 @@ export class Tracker {
updateData(dataTrackerChunk: DataTrackerChunk) {
if (dataTrackerChunk.data.pos) {
this.setPos(dataTrackerChunk.data.pos.data.x, dataTrackerChunk.data.pos.data.y, dataTrackerChunk.data.pos.data.z);
this.setPos(
dataTrackerChunk.data.pos.data.x,
dataTrackerChunk.data.pos.data.y,
dataTrackerChunk.data.pos.data.z
);
}
if (dataTrackerChunk.data.speed) {
@@ -176,7 +186,11 @@ export class Tracker {
}
if (dataTrackerChunk.data.ori) {
this.setOri(dataTrackerChunk.data.ori.data.x, dataTrackerChunk.data.ori.data.y, dataTrackerChunk.data.ori.data.z);
this.setOri(
dataTrackerChunk.data.ori.data.x,
dataTrackerChunk.data.ori.data.y,
dataTrackerChunk.data.ori.data.z
);
}
if (dataTrackerChunk.data.status) {
@@ -207,7 +221,10 @@ export class Tracker {
export function TrackerFromInfo(infoTrackerChunk: InfoTrackerChunk) {
if (infoTrackerChunk.data) {
return new Tracker(infoTrackerChunk.chunk.header.id, infoTrackerChunk.data.trackerName.data.trackerName);
return new Tracker(
infoTrackerChunk.chunk.header.id,
infoTrackerChunk.data.trackerName.data.trackerName
);
}
return undefined;
}
+165 -74
View File
@@ -5,7 +5,9 @@ import { describe, it } from 'node:test';
const goodTests = [
{
description: 'DataTrackerPosChunk',
bytes: new Uint8Array([0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
bytes: new Uint8Array([
0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
expected: {
chunk: {
chunkData: new Uint8Array([0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
@@ -21,7 +23,9 @@ const goodTests = [
},
{
description: 'DataTrackerSpeedChunk',
bytes: new Uint8Array([1, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
bytes: new Uint8Array([
1, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
expected: {
chunk: {
chunkData: new Uint8Array([0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
@@ -37,7 +41,9 @@ const goodTests = [
},
{
description: 'DataTrackerOriChunk',
bytes: new Uint8Array([2, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
bytes: new Uint8Array([
2, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
expected: {
chunk: {
chunkData: new Uint8Array([0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
@@ -67,7 +73,9 @@ const goodTests = [
},
{
description: 'DataTrackerAccelChunk',
bytes: new Uint8Array([4, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
bytes: new Uint8Array([
4, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
expected: {
chunk: {
chunkData: new Uint8Array([0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
@@ -83,7 +91,9 @@ const goodTests = [
},
{
description: 'DataTrackerTrgtPosChunk',
bytes: new Uint8Array([5, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
bytes: new Uint8Array([
5, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
expected: {
chunk: {
chunkData: new Uint8Array([0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
@@ -114,25 +124,29 @@ const goodTests = [
{
description: 'DataTrackerChunk',
bytes: new Uint8Array([
1, 0, 100, 128, 0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 1, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0,
0, 64, 64, 2, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0, 128, 63, 4, 0, 12, 0, 0, 0,
128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 5, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 6, 0, 8, 0, 210, 2,
150, 73, 0, 0, 0, 0,
1, 0, 100, 128, 0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 1,
0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 2, 0, 12, 0, 0, 0,
128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0, 128, 63, 4, 0, 12,
0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 5, 0, 12, 0, 0, 0, 128, 63,
0, 0, 0, 64, 0, 0, 64, 64, 6, 0, 8, 0, 210, 2, 150, 73, 0, 0, 0, 0,
]),
expected: {
chunk: {
chunkData: new Uint8Array([
0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 1, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
2, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0, 128, 63, 4, 0, 12, 0, 0, 0, 128, 63,
0, 0, 0, 64, 0, 0, 64, 64, 5, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 6, 0, 8, 0, 210, 2, 150, 73,
0, 0, 0, 0,
0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 1, 0, 12, 0, 0,
0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 2, 0, 12, 0, 0, 0, 128, 63, 0,
0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0, 128, 63, 4, 0, 12, 0, 0, 0,
128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 5, 0, 12, 0, 0, 0, 128, 63, 0, 0,
0, 64, 0, 0, 64, 64, 6, 0, 8, 0, 210, 2, 150, 73, 0, 0, 0, 0,
]),
header: { dataLen: 100, id: 1, hasSubchunks: true },
},
data: {
pos: {
chunk: {
chunkData: new Uint8Array([0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
chunkData: new Uint8Array([
0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
header: { dataLen: 12, id: 0, hasSubchunks: false },
},
data: {
@@ -143,7 +157,9 @@ const goodTests = [
},
speed: {
chunk: {
chunkData: new Uint8Array([0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
chunkData: new Uint8Array([
0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
header: { dataLen: 12, id: 1, hasSubchunks: false },
},
data: {
@@ -154,7 +170,9 @@ const goodTests = [
},
ori: {
chunk: {
chunkData: new Uint8Array([0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
chunkData: new Uint8Array([
0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
header: { dataLen: 12, id: 2, hasSubchunks: false },
},
data: {
@@ -174,7 +192,9 @@ const goodTests = [
},
accel: {
chunk: {
chunkData: new Uint8Array([0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
chunkData: new Uint8Array([
0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
header: { dataLen: 12, id: 4, hasSubchunks: false },
},
data: {
@@ -185,7 +205,9 @@ const goodTests = [
},
trgtpos: {
chunk: {
chunkData: new Uint8Array([0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
chunkData: new Uint8Array([
0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
header: { dataLen: 12, id: 5, hasSubchunks: false },
},
data: {
@@ -210,18 +232,22 @@ const goodTests = [
{
description: 'DataTrackerListChunk',
bytes: new Uint8Array([
1, 0, 104, 128, 1, 0, 100, 128, 0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 1, 0, 12, 0, 0, 0, 128, 63,
0, 0, 0, 64, 0, 0, 64, 64, 2, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0, 128, 63, 4, 0,
12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 5, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 6, 0, 8,
0, 210, 2, 150, 73, 0, 0, 0, 0,
1, 0, 104, 128, 1, 0, 100, 128, 0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64,
0, 0, 64, 64, 1, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 2, 0,
12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0, 128,
63, 4, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 5, 0, 12, 0, 0,
0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 6, 0, 8, 0, 210, 2, 150, 73, 0, 0,
0, 0,
]),
expected: {
chunk: {
chunkData: new Uint8Array([
1, 0, 100, 128, 0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 1, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0,
64, 0, 0, 64, 64, 2, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0, 128, 63, 4, 0, 12,
0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 5, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 6, 0, 8,
0, 210, 2, 150, 73, 0, 0, 0, 0,
1, 0, 100, 128, 0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
1, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 2, 0, 12, 0, 0,
0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0, 128, 63, 4,
0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 5, 0, 12, 0, 0, 0,
128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 6, 0, 8, 0, 210, 2, 150, 73, 0, 0,
0, 0,
]),
header: { dataLen: 104, id: 1, hasSubchunks: true },
},
@@ -230,17 +256,21 @@ const goodTests = [
{
chunk: {
chunkData: new Uint8Array([
0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 1, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0,
64, 64, 2, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0, 128, 63, 4, 0, 12, 0,
0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 5, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 6, 0,
8, 0, 210, 2, 150, 73, 0, 0, 0, 0,
0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 1, 0, 12,
0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 2, 0, 12, 0, 0, 0,
128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0, 128, 63,
4, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 5, 0, 12,
0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 6, 0, 8, 0, 210, 2,
150, 73, 0, 0, 0, 0,
]),
header: { dataLen: 100, id: 1, hasSubchunks: true },
},
data: {
pos: {
chunk: {
chunkData: new Uint8Array([0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
chunkData: new Uint8Array([
0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
header: { dataLen: 12, id: 0, hasSubchunks: false },
},
data: {
@@ -251,7 +281,9 @@ const goodTests = [
},
speed: {
chunk: {
chunkData: new Uint8Array([0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
chunkData: new Uint8Array([
0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
header: { dataLen: 12, id: 1, hasSubchunks: false },
},
data: {
@@ -262,7 +294,9 @@ const goodTests = [
},
ori: {
chunk: {
chunkData: new Uint8Array([0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
chunkData: new Uint8Array([
0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
header: { dataLen: 12, id: 2, hasSubchunks: false },
},
data: {
@@ -282,7 +316,9 @@ const goodTests = [
},
accel: {
chunk: {
chunkData: new Uint8Array([0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
chunkData: new Uint8Array([
0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
header: { dataLen: 12, id: 4, hasSubchunks: false },
},
data: {
@@ -293,7 +329,9 @@ const goodTests = [
},
trgtpos: {
chunk: {
chunkData: new Uint8Array([0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
chunkData: new Uint8Array([
0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
header: { dataLen: 12, id: 5, hasSubchunks: false },
},
data: {
@@ -321,25 +359,33 @@ const goodTests = [
{
description: 'DataPacketChunk',
bytes: new Uint8Array([
85, 103, 124, 128, 0, 0, 12, 0, 210, 2, 150, 73, 0, 0, 0, 0, 2, 3, 1, 123, 1, 0, 104, 128, 1, 0, 100, 128, 0, 0,
12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 1, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 2, 0, 12,
0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0, 128, 63, 4, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64,
0, 0, 64, 64, 5, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 6, 0, 8, 0, 210, 2, 150, 73, 0, 0, 0, 0,
85, 103, 124, 128, 0, 0, 12, 0, 210, 2, 150, 73, 0, 0, 0, 0, 2, 3, 1, 123,
1, 0, 104, 128, 1, 0, 100, 128, 0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64,
0, 0, 64, 64, 1, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 2, 0,
12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0, 128,
63, 4, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 5, 0, 12, 0, 0,
0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 6, 0, 8, 0, 210, 2, 150, 73, 0, 0,
0, 0,
]),
expected: {
chunk: {
chunkData: new Uint8Array([
0, 0, 12, 0, 210, 2, 150, 73, 0, 0, 0, 0, 2, 3, 1, 123, 1, 0, 104, 128, 1, 0, 100, 128, 0, 0, 12, 0, 0, 0,
128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 1, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 2, 0, 12, 0, 0, 0,
128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0, 128, 63, 4, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0,
64, 64, 5, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 6, 0, 8, 0, 210, 2, 150, 73, 0, 0, 0, 0,
0, 0, 12, 0, 210, 2, 150, 73, 0, 0, 0, 0, 2, 3, 1, 123, 1, 0, 104,
128, 1, 0, 100, 128, 0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0,
64, 64, 1, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 2, 0,
12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0,
128, 63, 4, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 5, 0,
12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 6, 0, 8, 0, 210, 2,
150, 73, 0, 0, 0, 0,
]),
header: { dataLen: 124, id: 26453, hasSubchunks: true },
},
data: {
packetHeader: {
chunk: {
chunkData: new Uint8Array([210, 2, 150, 73, 0, 0, 0, 0, 2, 3, 1, 123]),
chunkData: new Uint8Array([
210, 2, 150, 73, 0, 0, 0, 0, 2, 3, 1, 123,
]),
header: { dataLen: 12, id: 0, hasSubchunks: false },
},
data: {
@@ -353,10 +399,12 @@ const goodTests = [
trackerList: {
chunk: {
chunkData: new Uint8Array([
1, 0, 100, 128, 0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 1, 0, 12, 0, 0, 0, 128, 63, 0, 0,
0, 64, 0, 0, 64, 64, 2, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0, 128, 63, 4,
0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 5, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
6, 0, 8, 0, 210, 2, 150, 73, 0, 0, 0, 0,
1, 0, 100, 128, 0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64,
64, 1, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 2, 0,
12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0,
128, 63, 4, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 5,
0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 6, 0, 8, 0,
210, 2, 150, 73, 0, 0, 0, 0,
]),
header: { dataLen: 104, id: 1, hasSubchunks: true },
},
@@ -365,9 +413,11 @@ const goodTests = [
{
chunk: {
chunkData: new Uint8Array([
0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 1, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0,
0, 64, 64, 2, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0, 128, 63, 4, 0,
12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 5, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64,
0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 1, 0,
12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 2, 0, 12,
0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0,
0, 128, 63, 4, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0,
64, 64, 5, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64,
64, 6, 0, 8, 0, 210, 2, 150, 73, 0, 0, 0, 0,
]),
header: { dataLen: 100, id: 1, hasSubchunks: true },
@@ -375,7 +425,9 @@ const goodTests = [
data: {
pos: {
chunk: {
chunkData: new Uint8Array([0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
chunkData: new Uint8Array([
0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
header: { dataLen: 12, id: 0, hasSubchunks: false },
},
data: {
@@ -386,7 +438,9 @@ const goodTests = [
},
speed: {
chunk: {
chunkData: new Uint8Array([0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
chunkData: new Uint8Array([
0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
header: { dataLen: 12, id: 1, hasSubchunks: false },
},
data: {
@@ -397,7 +451,9 @@ const goodTests = [
},
ori: {
chunk: {
chunkData: new Uint8Array([0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
chunkData: new Uint8Array([
0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
header: { dataLen: 12, id: 2, hasSubchunks: false },
},
data: {
@@ -417,7 +473,9 @@ const goodTests = [
},
accel: {
chunk: {
chunkData: new Uint8Array([0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
chunkData: new Uint8Array([
0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
header: { dataLen: 12, id: 4, hasSubchunks: false },
},
data: {
@@ -428,7 +486,9 @@ const goodTests = [
},
trgtpos: {
chunk: {
chunkData: new Uint8Array([0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
chunkData: new Uint8Array([
0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
header: { dataLen: 12, id: 5, hasSubchunks: false },
},
data: {
@@ -471,10 +531,14 @@ const goodTests = [
},
{
description: 'InfoSystemNameChunk',
bytes: new Uint8Array([1, 0, 10, 0, 80, 83, 78, 32, 83, 101, 114, 118, 101, 114]),
bytes: new Uint8Array([
1, 0, 10, 0, 80, 83, 78, 32, 83, 101, 114, 118, 101, 114,
]),
expected: {
chunk: {
chunkData: new Uint8Array([80, 83, 78, 32, 83, 101, 114, 118, 101, 114]),
chunkData: new Uint8Array([
80, 83, 78, 32, 83, 101, 114, 118, 101, 114,
]),
header: { dataLen: 10, id: 1, hasSubchunks: false },
},
data: {
@@ -485,10 +549,14 @@ const goodTests = [
},
{
description: 'InfoTrackerChunk',
bytes: new Uint8Array([1, 0, 13, 128, 0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49]),
bytes: new Uint8Array([
1, 0, 13, 128, 0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49,
]),
expected: {
chunk: {
chunkData: new Uint8Array([0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49]),
chunkData: new Uint8Array([
0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49,
]),
header: { dataLen: 13, id: 1, hasSubchunks: true },
},
data: {
@@ -507,23 +575,32 @@ const goodTests = [
},
{
description: 'InfoTrackerListChunk',
bytes: new Uint8Array([2, 0, 17, 128, 1, 0, 13, 128, 0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49]),
bytes: new Uint8Array([
2, 0, 17, 128, 1, 0, 13, 128, 0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114,
32, 49,
]),
expected: {
chunk: {
chunkData: new Uint8Array([1, 0, 13, 128, 0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49]),
chunkData: new Uint8Array([
1, 0, 13, 128, 0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49,
]),
header: { dataLen: 17, id: 2, hasSubchunks: true },
},
data: {
trackers: [
{
chunk: {
chunkData: new Uint8Array([0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49]),
chunkData: new Uint8Array([
0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49,
]),
header: { dataLen: 13, id: 1, hasSubchunks: true },
},
data: {
trackerName: {
chunk: {
chunkData: new Uint8Array([84, 114, 97, 99, 107, 101, 114, 32, 49]),
chunkData: new Uint8Array([
84, 114, 97, 99, 107, 101, 114, 32, 49,
]),
header: { dataLen: 9, id: 0, hasSubchunks: false },
},
data: {
@@ -539,7 +616,9 @@ const goodTests = [
},
{
description: 'PacketHeaderChunk',
bytes: new Uint8Array([0, 0, 12, 0, 210, 2, 150, 73, 0, 0, 0, 0, 2, 3, 1, 123]),
bytes: new Uint8Array([
0, 0, 12, 0, 210, 2, 150, 73, 0, 0, 0, 0, 2, 3, 1, 123,
]),
expected: {
chunk: {
chunkData: new Uint8Array([210, 2, 150, 73, 0, 0, 0, 0, 2, 3, 1, 123]),
@@ -558,21 +637,25 @@ const goodTests = [
{
description: 'InfoPacketChunk',
bytes: new Uint8Array([
86, 103, 51, 128, 0, 0, 12, 0, 210, 2, 150, 73, 0, 0, 0, 0, 2, 3, 1, 123, 1, 0, 10, 0, 80, 83, 78, 32, 83, 101,
114, 118, 101, 114, 2, 0, 17, 128, 1, 0, 13, 128, 0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49,
86, 103, 51, 128, 0, 0, 12, 0, 210, 2, 150, 73, 0, 0, 0, 0, 2, 3, 1, 123,
1, 0, 10, 0, 80, 83, 78, 32, 83, 101, 114, 118, 101, 114, 2, 0, 17, 128,
1, 0, 13, 128, 0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49,
]),
expected: {
chunk: {
chunkData: new Uint8Array([
0, 0, 12, 0, 210, 2, 150, 73, 0, 0, 0, 0, 2, 3, 1, 123, 1, 0, 10, 0, 80, 83, 78, 32, 83, 101, 114, 118, 101,
114, 2, 0, 17, 128, 1, 0, 13, 128, 0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49,
0, 0, 12, 0, 210, 2, 150, 73, 0, 0, 0, 0, 2, 3, 1, 123, 1, 0, 10, 0,
80, 83, 78, 32, 83, 101, 114, 118, 101, 114, 2, 0, 17, 128, 1, 0, 13,
128, 0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49,
]),
header: { dataLen: 51, id: 26454, hasSubchunks: true },
},
data: {
packetHeader: {
chunk: {
chunkData: new Uint8Array([210, 2, 150, 73, 0, 0, 0, 0, 2, 3, 1, 123]),
chunkData: new Uint8Array([
210, 2, 150, 73, 0, 0, 0, 0, 2, 3, 1, 123,
]),
header: { dataLen: 12, id: 0, hasSubchunks: false },
},
data: {
@@ -585,7 +668,9 @@ const goodTests = [
},
systemName: {
chunk: {
chunkData: new Uint8Array([80, 83, 78, 32, 83, 101, 114, 118, 101, 114]),
chunkData: new Uint8Array([
80, 83, 78, 32, 83, 101, 114, 118, 101, 114,
]),
header: { dataLen: 10, id: 1, hasSubchunks: false },
},
data: {
@@ -594,20 +679,26 @@ const goodTests = [
},
trackerList: {
chunk: {
chunkData: new Uint8Array([1, 0, 13, 128, 0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49]),
chunkData: new Uint8Array([
1, 0, 13, 128, 0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49,
]),
header: { dataLen: 17, id: 2, hasSubchunks: true },
},
data: {
trackers: [
{
chunk: {
chunkData: new Uint8Array([0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49]),
chunkData: new Uint8Array([
0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49,
]),
header: { dataLen: 13, id: 1, hasSubchunks: true },
},
data: {
trackerName: {
chunk: {
chunkData: new Uint8Array([84, 114, 97, 99, 107, 101, 114, 32, 49]),
chunkData: new Uint8Array([
84, 114, 97, 99, 107, 101, 114, 32, 49,
]),
header: { dataLen: 9, id: 0, hasSubchunks: false },
},
data: {
+77 -36
View File
@@ -5,17 +5,23 @@ import { describe, it } from 'node:test';
const goodTests = [
{
description: 'DataTrackerPosChunk',
expected: new Uint8Array([0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
expected: new Uint8Array([
0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
bytes: Encoders.DataTrackerPosChunk(1.0, 2.0, 3.0),
},
{
description: 'DataTrackerSpeedChunk',
expected: new Uint8Array([1, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
expected: new Uint8Array([
1, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
bytes: Encoders.DataTrackerSpeedChunk(1.0, 2.0, 3.0),
},
{
description: 'DataTrackerOriChunk',
expected: new Uint8Array([2, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
expected: new Uint8Array([
2, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
bytes: Encoders.DataTrackerOriChunk(1.0, 2.0, 3.0),
},
{
@@ -25,12 +31,16 @@ const goodTests = [
},
{
description: 'DataTrackerAccelChunk',
expected: new Uint8Array([4, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
expected: new Uint8Array([
4, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
bytes: Encoders.DataTrackerAccelChunk(1.0, 2.0, 3.0),
},
{
description: 'DataTrackerTrgtposChunk',
expected: new Uint8Array([5, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
expected: new Uint8Array([
5, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
]),
bytes: Encoders.DataTrackerTrgtposChunk(1.0, 2.0, 3.0),
},
{
@@ -41,10 +51,11 @@ const goodTests = [
{
description: 'DataTrackerChunk',
expected: new Uint8Array([
1, 0, 100, 128, 0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 1, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0,
0, 64, 64, 2, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0, 128, 63, 4, 0, 12, 0, 0, 0,
128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 5, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 6, 0, 8, 0, 210, 2,
150, 73, 0, 0, 0, 0,
1, 0, 100, 128, 0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 1,
0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 2, 0, 12, 0, 0, 0,
128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0, 128, 63, 4, 0, 12,
0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 5, 0, 12, 0, 0, 0, 128, 63,
0, 0, 0, 64, 0, 0, 64, 64, 6, 0, 8, 0, 210, 2, 150, 73, 0, 0, 0, 0,
]),
bytes: Encoders.DataTrackerChunk(1, [
new Uint8Array([0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64]),
@@ -59,75 +70,105 @@ const goodTests = [
{
description: 'DataTrackerListChunk',
expected: new Uint8Array([
1, 0, 104, 128, 1, 0, 100, 128, 0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 1, 0, 12, 0, 0, 0, 128, 63,
0, 0, 0, 64, 0, 0, 64, 64, 2, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0, 128, 63, 4, 0,
12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 5, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 6, 0, 8,
0, 210, 2, 150, 73, 0, 0, 0, 0,
1, 0, 104, 128, 1, 0, 100, 128, 0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64,
0, 0, 64, 64, 1, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 2, 0,
12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0, 128,
63, 4, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 5, 0, 12, 0, 0,
0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 6, 0, 8, 0, 210, 2, 150, 73, 0, 0,
0, 0,
]),
bytes: Encoders.DataTrackerListChunk([
new Uint8Array([
1, 0, 100, 128, 0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 1, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64,
0, 0, 64, 64, 2, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0, 128, 63, 4, 0, 12, 0, 0,
0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 5, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 6, 0, 8, 0, 210,
2, 150, 73, 0, 0, 0, 0,
1, 0, 100, 128, 0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64,
1, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 2, 0, 12, 0, 0,
0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0, 128, 63, 4, 0,
12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 5, 0, 12, 0, 0, 0, 128,
63, 0, 0, 0, 64, 0, 0, 64, 64, 6, 0, 8, 0, 210, 2, 150, 73, 0, 0, 0, 0,
]),
]),
},
{
description: 'DataPacketChunk',
expected: new Uint8Array([
85, 103, 124, 128, 0, 0, 12, 0, 210, 2, 150, 73, 0, 0, 0, 0, 2, 3, 1, 123, 1, 0, 104, 128, 1, 0, 100, 128, 0, 0,
12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 1, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 2, 0, 12,
0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0, 128, 63, 4, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64,
0, 0, 64, 64, 5, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 6, 0, 8, 0, 210, 2, 150, 73, 0, 0, 0, 0,
85, 103, 124, 128, 0, 0, 12, 0, 210, 2, 150, 73, 0, 0, 0, 0, 2, 3, 1, 123,
1, 0, 104, 128, 1, 0, 100, 128, 0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64,
0, 0, 64, 64, 1, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 2, 0,
12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0, 128,
63, 4, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 5, 0, 12, 0, 0,
0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 6, 0, 8, 0, 210, 2, 150, 73, 0, 0,
0, 0,
]),
bytes: Encoders.DataPacketChunk(
new Uint8Array([0, 0, 12, 0, 210, 2, 150, 73, 0, 0, 0, 0, 2, 3, 1, 123]),
new Uint8Array([
1, 0, 104, 128, 1, 0, 100, 128, 0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 1, 0, 12, 0, 0, 0, 128,
63, 0, 0, 0, 64, 0, 0, 64, 64, 2, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0, 128, 63,
4, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 5, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 6,
0, 8, 0, 210, 2, 150, 73, 0, 0, 0, 0,
1, 0, 104, 128, 1, 0, 100, 128, 0, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64,
0, 0, 64, 64, 1, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 2,
0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 3, 0, 4, 0, 0, 0,
128, 63, 4, 0, 12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 5, 0,
12, 0, 0, 0, 128, 63, 0, 0, 0, 64, 0, 0, 64, 64, 6, 0, 8, 0, 210, 2,
150, 73, 0, 0, 0, 0,
])
),
},
{
description: 'InfoTrackerNameChunk',
expected: new Uint8Array([0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49]),
expected: new Uint8Array([
0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49,
]),
bytes: Encoders.InfoTrackerNameChunk('Tracker 1'),
},
{
description: 'InfoSystemNameChunk',
expected: new Uint8Array([1, 0, 10, 0, 80, 83, 78, 32, 83, 101, 114, 118, 101, 114]),
expected: new Uint8Array([
1, 0, 10, 0, 80, 83, 78, 32, 83, 101, 114, 118, 101, 114,
]),
bytes: Encoders.InfoSystemNameChunk('PSN Server'),
},
{
description: 'InfoTrackerChunk',
expected: new Uint8Array([1, 0, 13, 128, 0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49]),
bytes: Encoders.InfoTrackerChunk(1, new Uint8Array([0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49])),
expected: new Uint8Array([
1, 0, 13, 128, 0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49,
]),
bytes: Encoders.InfoTrackerChunk(
1,
new Uint8Array([0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49])
),
},
{
description: 'InfoTrackerListChunk',
expected: new Uint8Array([2, 0, 17, 128, 1, 0, 13, 128, 0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49]),
expected: new Uint8Array([
2, 0, 17, 128, 1, 0, 13, 128, 0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114,
32, 49,
]),
bytes: Encoders.InfoTrackerListChunk([
new Uint8Array([1, 0, 13, 128, 0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49]),
new Uint8Array([
1, 0, 13, 128, 0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49,
]),
]),
},
{
description: 'PacketHeaderChunk',
expected: new Uint8Array([0, 0, 12, 0, 210, 2, 150, 73, 0, 0, 0, 0, 2, 3, 1, 123]),
expected: new Uint8Array([
0, 0, 12, 0, 210, 2, 150, 73, 0, 0, 0, 0, 2, 3, 1, 123,
]),
bytes: Encoders.PacketHeaderChunk(1234567890n, 2, 3, 1, 123),
},
{
description: 'InfoPacketChunk',
expected: new Uint8Array([
86, 103, 51, 128, 0, 0, 12, 0, 210, 2, 150, 73, 0, 0, 0, 0, 2, 3, 1, 123, 1, 0, 10, 0, 80, 83, 78, 32, 83, 101,
114, 118, 101, 114, 2, 0, 17, 128, 1, 0, 13, 128, 0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49,
86, 103, 51, 128, 0, 0, 12, 0, 210, 2, 150, 73, 0, 0, 0, 0, 2, 3, 1, 123,
1, 0, 10, 0, 80, 83, 78, 32, 83, 101, 114, 118, 101, 114, 2, 0, 17, 128,
1, 0, 13, 128, 0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49,
]),
bytes: Encoders.InfoPacketChunk(
new Uint8Array([0, 0, 12, 0, 210, 2, 150, 73, 0, 0, 0, 0, 2, 3, 1, 123]),
new Uint8Array([1, 0, 10, 0, 80, 83, 78, 32, 83, 101, 114, 118, 101, 114]),
new Uint8Array([2, 0, 17, 128, 1, 0, 13, 128, 0, 0, 9, 0, 84, 114, 97, 99, 107, 101, 114, 32, 49])
new Uint8Array([
1, 0, 10, 0, 80, 83, 78, 32, 83, 101, 114, 118, 101, 114,
]),
new Uint8Array([
2, 0, 17, 128, 1, 0, 13, 128, 0, 0, 9, 0, 84, 114, 97, 99, 107, 101,
114, 32, 49,
])
),
},
];
+2 -2
View File
@@ -1,4 +1,4 @@
import { defineConfig } from 'tsdown'
import { defineConfig } from 'tsdown';
export default defineConfig({
entry: 'src/index.ts',
@@ -7,4 +7,4 @@ export default defineConfig({
esm: {},
cjs: {},
},
})
});