-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add device.delete #30
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,6 +83,23 @@ module.exports = class Ti84series { | |
flash: params.find(p => p.type == v.parameters.DUSB_PID_FREE_FLASH).value, | ||
}; | ||
} | ||
|
||
async delete(name, type) { | ||
await this._d.send({ | ||
type: v.virtualPacketTypes.DUSB_VPKT_MODIF_VAR, | ||
data: [ | ||
0, name.length, | ||
...b.asciiToBytes(name), | ||
...b.constructParameters([{ | ||
type: v.attributes.DUSB_AID_VAR_TYPE2, | ||
value: b.intToBytes(0xF0070000 + type, 4) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No bounds check on type. Sure, other parts are already doing it wrong too, but no need to introduce more low-quality code :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure that type should be a user-supplied value in the first place. How am I, as a user of Ideas:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The type that this accepts is the same that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An enumeration of types would work, but it would be a large enum, since types are model-dependent. libtifiles splits types across multiple types*.h files. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Really? Why is that? I assume because something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That, and also that different models have different types available in the first place. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check. Then I'd expect the API to allow the superset of types, convert the right ones and give an error if we try to use a type that isn't valid for the current model. Right..? :) |
||
}]), | ||
1, | ||
0, 0, 0, 0, 0 | ||
] | ||
}); | ||
await this._d.expect(v.virtualPacketTypes.DUSB_VPKT_DATA_ACK); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAICT, this, or expect() in device, does not handle error packets properly. See dusb_cmd_r_data_ack() in https://github.com/debrouxl/tilibs/blob/experimental2/libticalcs/trunk/src/dusb_cmd.cc . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds like something for a separate PR. |
||
} | ||
|
||
// Send a TI file to the calculator | ||
async sendFile(file) { | ||
|
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.
Any idea what this is or does? I'm guessing this name came from libticalc? Maybe we can name it something a bit more descriptive, or add a comment.
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.
Yes, it came from libticalcs. I'm not sure why it's separate from the other type attribute in the first place.
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.
TI logic ? :)