diff --git a/compile-services.js b/compile-services.js new file mode 100644 index 0000000..e11112c --- /dev/null +++ b/compile-services.js @@ -0,0 +1,18 @@ +const fs = require("fs") + +// usage: node compile-services.js ../jacdac-docs/jacdac-ts/jacdac-spec/dist/services.json + +const serv = JSON.parse(fs.readFileSync(process.argv[2], "utf8")) +let r = [] +serv.forEach(s => { + const id = Buffer.alloc(4) + id.writeUInt32LE(s.classIdentifier) + if (0x1fffff00 <= s.classIdentifier && s.classIdentifier <= 0x20000000) + return + console.log(id.toString("hex"), s.shortName) + r.push( + id, + Buffer.from(s.shortName + "\u0000", "utf8") + ) +}) +console.log(Buffer.concat(r).toString('hex').replace(/.{80}/g, f => f + "\n")) diff --git a/services.ts b/services.ts index 5a08f19..b043c02 100644 --- a/services.ts +++ b/services.ts @@ -1,3 +1,48 @@ +const servNames = hex` +0904141f616363656c65726f6d65746572006ea0ea1d61726361646547616d65706164000636c61f +617263616465536f756e64006c9e731c626172636f646552656164657200ea7c111e6261726f6d65 +74657200cf86c91a626974526164696f004899fa1f626f6f746c6f616465720063a2731462757474 +6f6e00d7b1571b62757a7a657200c9ad652863617061636974697665427574746f6e006ac5371f63 +686172616374657253637265656e0067d53016636f6c6f7200bfb9b715636f6d7061737300000000 +00636f6e74726f6c008a6b1a1464697374616e636500058ccf11646d7800c69d9c1665434f3200f2 +061b1e6779726f73636f706500c46d6c16686561727452617465006a5bb0186869644b6579626f61 +7264001cdc85186869644d6f75736500b810c81668756d696469747900f2ca6e1e696c6c756d696e +616e636500e536fa16696e646578656453637265656e004c36ed19696f744875620056748f106a6f +79737469636b00f848301e6c6564004b150d116c65644d617472697800e0006f126c656450697865 +6c001c9adc176c696768744c6576656c00ca1fdc126c6f6767657200889002136d61676e65746f6d +6574657200c82d06136d61747269784b65797061640086ac3d116d6963726f70686f6e6500d78c84 +1a6d6964694f757470757400789a0f146d6f64656c52756e6e65720049a779116d6f74696f6e00d8 +4c00176d6f746f72002b5ed5186d756c7469746f756368004647271f706f74656e74696f6d657465 +72005ac9a41f706f77657200c34017287072657373757265427574746f6e006a46c71670726f746f +5465737400b64ebb1070756c73654f78696d6574657200954c73137261696e476175676500281a8b +1a7265616c54696d65436c6f636b00b24c6c127265666c65637465644c696768740056e63f187265 +6c617900a2f08917726e6700667e4b1e726f6c654d616e6167657200c929fa10726f74617279456e +636f646572006bd0f419726f76657200c5e1901d73656e736f7241676772656761746f72000391fc +12736572766f004adc071173657474696e677300f7586119736576656e5365676d656e7444697370 +6c617900b3a34a1d736f696c4d6f69737475726500ca231717736f6c656e6f6964005d1aad14736f +756e644c6576656c0038d30314736f756e64506c61796572001ebc7a15736f756e64537065637472 +756d0095d9041273706565636853796e746865736973000294d21a737769746368000bb7431b7463 +700061c03a14746865726d6f636f75706c6500c7ba2114746865726d6f6d65746572009b8dc31574 +7261666669634c696768740097b5a51274766f6300900d6e1f7576496e64657800a2c43f18766962 +726174696f6e4d6f746f7200ed627b1477617465724c6576656c0040504d1f776569676874536361 +6c6500fae1aa1877696669002be96b1877696e64446972656374696f6e00bf1b591b77696e645370 +65656400 +` + +function servName(id: number) { + let ptr = 0 + while (ptr < servNames.length) { + let eptr = ptr + 4 + while (servNames[eptr]) + eptr++ + if (servNames.getNumber(NumberFormat.UInt32LE, ptr) == id) { + return servNames.slice(ptr + 4, eptr - ptr - 4).toString() + } + ptr = eptr + 1 + } + return hexNum(id) +} + class ServiceDesc { constructor( public classNum: number, @@ -133,7 +178,7 @@ function deviceView(d: jacdac.Device) { const id = d.services.getNumber(NumberFormat.UInt32LE, i) let s = serviceDescs.find(s => s.classNum == id) if (!s) - s = new ServiceDesc(id, "Service: " + hexNum(id), () => { }) + s = new ServiceDesc(id, "Service: " + servName(id), () => { }) services.push(s) }