diff --git a/src/website/index.html b/src/website/index.html index 45a1ae4..0c2c1ee 100644 --- a/src/website/index.html +++ b/src/website/index.html @@ -10,7 +10,7 @@
- + setTimeout(resolve, CLOCK_TIME)); + return new Promise((resolve) => setTimeout(resolve, Constants.CLOCK_TIME)); } stopWorkers(); - return new Promise((resolve) => setTimeout(resolve, CLOCK_TIME)); + return new Promise((resolve) => setTimeout(resolve, Constants.CLOCK_TIME)); } diff --git a/src/website/scripts/Packet.js b/src/website/scripts/Packet.js index f30d5d1..2e40bb2 100644 --- a/src/website/scripts/Packet.js +++ b/src/website/scripts/Packet.js @@ -1,6 +1,5 @@ - /** - * + * This class represents a packet containing a header, payload and checksum. */ class Packet { /** @@ -26,6 +25,8 @@ class Packet { #checksum = []; /** + * Creates a new packet with the given text as the payload. + * * @param {String} payloadText */ constructor(payloadText) { @@ -53,11 +54,11 @@ class Packet { } /** - * Turn a string into an array of ASCII code points. - * - * @param {String} text - * @return {Number[]} - */ + * Turns a string into an array of ASCII code points. + * + * @param {String} text + * @return {Number[]} + */ #textToCodePoints(text) { const codePoints = []; for (let i = 0; i < text.length; i++) { @@ -67,11 +68,11 @@ class Packet { } /** - * Turn a string into an bit array. - * - * @param {String} text - * @return {Number[]} - */ + * Turns a string into a bit array. + * + * @param {String} text + * @return {Number[]} + */ #textToBitArray(text) { const codePoints = this.#textToCodePoints(text); let bitArray = []; @@ -82,17 +83,22 @@ class Packet { } /** - * Calculate the checksum of the given array of bytes and return it - * as an bit array. - * - * @param {Number[]} bytes - * @return {Number[]} - */ + * Calculates the checksum of the given array of bytes and return it + * as a bit array. + * + * @param {Number[]} bytes + * @return {Number[]} + */ #calculateChecksum(bytes) { const checksum = Utility.crc8Autosar(bytes); return this.#numberToBitArray(checksum, 8); } + /** + * Returns all data of the packet as a bit array. + * + * @return {Number[]} + */ getData() { return [...this.#header, ...this.#payload, ...this.#checksum]; } diff --git a/src/website/scripts/Utility.js b/src/website/scripts/Utility.js index 1e6eb25..cb41225 100644 --- a/src/website/scripts/Utility.js +++ b/src/website/scripts/Utility.js @@ -1,7 +1,6 @@ class Utility { /** - * This method calculates the CRC-8-AUTOSAR checksum of the given - * array of bytes. + * Calculates the CRC-8-AUTOSAR checksum of the given array of bytes. * * This code is based on the code examples from the following page: * http://www.sunshine2k.de/articles/coding/crc/understanding_crc.html @@ -48,7 +47,7 @@ class Utility { } /** - * Take a bit array and encode the contents using manchester encoding. + * Eencode the contents of the given bit array using manchester encoding. * * @param {Number[]} bitArray * @return {Number[]} @@ -65,7 +64,7 @@ class Utility { } /** - * Set the information message on the page to the given string. + * Sets the information message on the page to the given string. * @param {String} text */ static setMessage(text) {