Skip to content

Commit

Permalink
Minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianscheit committed Feb 6, 2025
1 parent f8edce4 commit cc25244
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
5 changes: 2 additions & 3 deletions pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ <h2 class="error"></h2>
</form>
<section>
<h3>Send frame</h3>
<p>If there is already a master on the bus, this operation can cause a frame colision on the bus!</p>
<p>If there is already a master on the bus, this operation can cause a frame colision on the bus.</p>
<form name="send">
<fieldset>
<legend>Send any frame:</legend>
Expand All @@ -125,8 +125,7 @@ <h3>Send frame</h3>
</label>
<label>
Function code:
<input id="functionCode" type="number" name="functionCode" list="functionCodeList" min="0" max="255"
step="1" required></select>
<input id="functionCode" type="number" name="functionCode" list="functionCodeList" min="0" max="255" step="1" required></select>
<datalist id="functionCodeList"></datalist>
</label>
<label>
Expand Down
2 changes: 1 addition & 1 deletion src/frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class Frame {

getRow(): TableDataColumn[] {
return [
new TableDataColumn(Frame.getDateTime(), this.type),
new TableDataColumn(`${Frame.getDateTime()} (${this.type})`, this.type),
new TableDataColumn(`${this.slaveAddress} = 0x${Converters.byteToHex(this.slaveAddress!)}`, this.type),
new TableDataColumn(FunctionCodes.getDescription(this.functionCode), this.type),
new TableDataColumn(this.getDataLength().toString(), this.type),
Expand Down
2 changes: 1 addition & 1 deletion src/function-codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class FunctionCodes {
if (description) {
return this._getDescription(code, description);
}
return this._getDescription(code, '<UNKNOWN>');
return this._getDescription(code, '(UNKNOWN)');
}

private static _getDescription(code: number, description: string): string {
Expand Down
12 changes: 3 additions & 9 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,8 @@ if (!serial) {
Dom.serialForm.setFieldsetDisabled(true);
}

Dom.clearSnifferButton.addEventListener('click', () => {
clearSniffingTable();
});
Dom.downloadSnifferButton.addEventListener('click', () => {
downloadAllSniffedEntries();
});
Dom.clearSnifferButton.addEventListener('click', () => clearSniffingTable());
Dom.downloadSnifferButton.addEventListener('click', () => downloadAllSniffedEntries());

Dom.serialForm.submit = (formData) => {
formData.baudRate = +formData.baudRate;
Expand Down Expand Up @@ -81,9 +77,7 @@ Dom.sendForm.submit = (formData) => {
}
const frameBytes: number[] = [formData.slaveAddress, formData.functionCode, ...bytes];
insertFrameRow(new Frame([...frameBytes], 'send'));
if (send) {
send(frameBytes);
}
send?.(frameBytes);
};

// intTest();

0 comments on commit cc25244

Please sign in to comment.