-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow setting/disabling Emergency Stop during setup/via Serial comman…
…ds (#269) * Upload port of @nullstalgia 's implementation Title: Allow setting/disabling Emergency Stop during setup/via Serial commands Date: April 19th 2024 Co-Authored-By: nullstalgia <[email protected]> * Read from config and fix gpio num types * Add SerialInput handler * Remove STD's from integers * Use intconv for SerialInputHandler * Update schemas * Remove annoying unnecessary warning * Finish EStop config implementation * More work is needed.... rip * Fix extra logging areas * Fix panic call * Use new convert methods * Undo formatting changes in Common.h * Update schemas * Fix argument order, and sort all remaining orders * Revert to default config if null * More EStopConfig fixes * Oops --------- Co-authored-by: nullstalgia <[email protected]>
- Loading branch information
1 parent
0a7e104
commit df27b6a
Showing
43 changed files
with
1,130 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
[submodule "schemas"] | ||
path = schemas | ||
url = https://github.com/OpenShock/flatbuffers-schemas | ||
branch = feature/estop-config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Builder as FlatbufferBuilder } from 'flatbuffers'; | ||
import { LocalToHubMessage } from '$lib/_fbs/open-shock/serialization/local/local-to-hub-message'; | ||
import { LocalToHubMessagePayload } from '$lib/_fbs/open-shock/serialization/local/local-to-hub-message-payload'; | ||
import { SetEstopEnabledCommand } from '$lib/_fbs/open-shock/serialization/local/set-estop-enabled-command'; | ||
|
||
export function SerializeSetEstopEnabledCommand(enabled: boolean): Uint8Array { | ||
const fbb = new FlatbufferBuilder(64); | ||
|
||
const cmdOffset = SetEstopEnabledCommand.createSetEstopEnabledCommand(fbb, enabled); | ||
|
||
const payloadOffset = LocalToHubMessage.createLocalToHubMessage(fbb, LocalToHubMessagePayload.SetEstopEnabledCommand, cmdOffset); | ||
|
||
fbb.finish(payloadOffset); | ||
|
||
return fbb.asUint8Array(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Builder as FlatbufferBuilder } from 'flatbuffers'; | ||
import { LocalToHubMessage } from '$lib/_fbs/open-shock/serialization/local/local-to-hub-message'; | ||
import { LocalToHubMessagePayload } from '$lib/_fbs/open-shock/serialization/local/local-to-hub-message-payload'; | ||
import { SetEstopPinCommand } from '$lib/_fbs/open-shock/serialization/local/set-estop-pin-command'; | ||
|
||
export function SerializeSetEstopPinCommand(pin: number): Uint8Array { | ||
const fbb = new FlatbufferBuilder(64); | ||
|
||
const cmdOffset = SetEstopPinCommand.createSetEstopPinCommand(fbb, pin); | ||
|
||
const payloadOffset = LocalToHubMessage.createLocalToHubMessage(fbb, LocalToHubMessagePayload.SetEstopPinCommand, cmdOffset); | ||
|
||
fbb.finish(payloadOffset); | ||
|
||
return fbb.asUint8Array(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
frontend/src/lib/_fbs/open-shock/serialization/configuration/estop-config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// automatically generated by the FlatBuffers compiler, do not modify | ||
|
||
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */ | ||
|
||
import * as flatbuffers from 'flatbuffers'; | ||
|
||
export class EStopConfig { | ||
bb: flatbuffers.ByteBuffer|null = null; | ||
bb_pos = 0; | ||
__init(i:number, bb:flatbuffers.ByteBuffer):EStopConfig { | ||
this.bb_pos = i; | ||
this.bb = bb; | ||
return this; | ||
} | ||
|
||
static getRootAsEStopConfig(bb:flatbuffers.ByteBuffer, obj?:EStopConfig):EStopConfig { | ||
return (obj || new EStopConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb); | ||
} | ||
|
||
static getSizePrefixedRootAsEStopConfig(bb:flatbuffers.ByteBuffer, obj?:EStopConfig):EStopConfig { | ||
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); | ||
return (obj || new EStopConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb); | ||
} | ||
|
||
enabled():boolean { | ||
const offset = this.bb!.__offset(this.bb_pos, 4); | ||
return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; | ||
} | ||
|
||
/** | ||
* The GPIO pin connected to the E-Stop button | ||
*/ | ||
gpioPin():number { | ||
const offset = this.bb!.__offset(this.bb_pos, 6); | ||
return offset ? this.bb!.readUint8(this.bb_pos + offset) : 0; | ||
} | ||
|
||
static startEStopConfig(builder:flatbuffers.Builder) { | ||
builder.startObject(2); | ||
} | ||
|
||
static addEnabled(builder:flatbuffers.Builder, enabled:boolean) { | ||
builder.addFieldInt8(0, +enabled, +false); | ||
} | ||
|
||
static addGpioPin(builder:flatbuffers.Builder, gpioPin:number) { | ||
builder.addFieldInt8(1, gpioPin, 0); | ||
} | ||
|
||
static endEStopConfig(builder:flatbuffers.Builder):flatbuffers.Offset { | ||
const offset = builder.endObject(); | ||
return offset; | ||
} | ||
|
||
static createEStopConfig(builder:flatbuffers.Builder, enabled:boolean, gpioPin:number):flatbuffers.Offset { | ||
EStopConfig.startEStopConfig(builder); | ||
EStopConfig.addEnabled(builder, enabled); | ||
EStopConfig.addGpioPin(builder, gpioPin); | ||
return EStopConfig.endEStopConfig(builder); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
df27b6a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cpp-Linter Report⚠️
Some files did not pass the configured checks!
clang-format reports: 5 file(s) not formatted
Have any feedback or feature suggestions? Share it here.