mirror of
https://github.com/lights0123/n-link.git
synced 2025-01-03 15:15:26 +00:00
Use latest libnspire changes
This commit is contained in:
parent
2f63381267
commit
bdd8ad0790
|
@ -286,7 +286,7 @@ static void handlePacket(struct nspire_handle *nsp_handle, NNSEMessage *message,
|
|||
if(!writePacket(handle, &ack))
|
||||
printf("Failed to ack\n");
|
||||
}
|
||||
printf("%d", message->service);
|
||||
printf("SERVICE %d", message->service);
|
||||
switch(message->service & ~AckFlag)
|
||||
{
|
||||
case AddrReqService:
|
||||
|
@ -298,19 +298,26 @@ static void handlePacket(struct nspire_handle *nsp_handle, NNSEMessage *message,
|
|||
#ifdef DEBUG
|
||||
printf("Got request from client %s (product id %c%c)\n", &req->clientID[12], req->clientID[10], req->clientID[11]);
|
||||
#endif
|
||||
|
||||
NNSEMessage_AddrResp resp = {};
|
||||
/* Sending this somehow introduces issues like the time request not
|
||||
arriving or the calc responding with yet another address request.
|
||||
// Address release request. Not sure how that works.
|
||||
NNSEMessage_AddrResp resp{};
|
||||
resp.hdr.service = message->service;
|
||||
resp.addr = AddrCalc;
|
||||
|
||||
if(!sendMessage(handle, resp))
|
||||
if(!sendMessage(resp))
|
||||
printf("Failed to send message\n");
|
||||
*/
|
||||
|
||||
NNSEMessage_AddrResp resp2 = {};
|
||||
resp2.hdr.service = message->service;
|
||||
resp2.addr = 0x80; // No idea
|
||||
|
||||
if(!sendMessage(handle, resp2))
|
||||
// In some cases on HW and in Firebird always after reconnecting
|
||||
// it ignores the first packet for some reason. So just send it
|
||||
// twice (the seqno doesn't really matter at this point), if it
|
||||
// receives both it'll ignore the second one.
|
||||
if(!sendMessage(handle, resp2) || !sendMessage(handle, resp2))
|
||||
printf("Failed to send message\n");
|
||||
|
||||
break;
|
||||
|
@ -408,7 +415,7 @@ int packet_send_cx2(struct nspire_handle *nsp_handle, char *data, int size)
|
|||
printf("packet_send_cx2");
|
||||
if(!assureReady(nsp_handle))
|
||||
return -NSPIRE_ERR_BUSY;
|
||||
|
||||
printf("assuredReady");
|
||||
auto *handle = nsp_handle->device.dev;
|
||||
|
||||
int len = sizeof(NNSEMessage) + size;
|
||||
|
|
|
@ -64,6 +64,7 @@ int nspire_init(nspire_handle_t **ptr, libusb_device_handle *dev, bool is_cx2) {
|
|||
return NSPIRE_ERR_SUCCESS;
|
||||
|
||||
error_free_usb:
|
||||
printf("err %d", ret);
|
||||
usb_free_device(&h->device);
|
||||
error:
|
||||
free(h);
|
||||
|
|
Binary file not shown.
|
@ -53,6 +53,7 @@ pub unsafe extern "C" fn printf(format: *const u8, mut args: ...) -> c_int {
|
|||
}
|
||||
let mut s = String::new();
|
||||
printf::func(format as _, args.as_va_list(), printf::to_write(&mut s));
|
||||
s.trim_end();
|
||||
log(&s);
|
||||
0
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ pub fn to_write<'a>(w: &'a mut impl fmt::Write) -> impl FnMut(Argument) + 'a {
|
|||
Argument::Extra(d) => {w.write_str(&String::from_utf8_lossy(d));},
|
||||
Argument::Hex(len, data) => {write!(w, "{:#0width$x}", data, width=len as usize);},
|
||||
Argument::Int(data) => {write!(w, "{}", data);},
|
||||
Argument::String(data) => {write!(w, "{}", data.to_string_lossy());},
|
||||
Argument::Char(data) => {write!(w, "{}", data as char);},
|
||||
e => {dbg!(e);},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -202,10 +202,11 @@ pub unsafe extern "C" fn libusb_bulk_transfer(
|
|||
) {
|
||||
Ok(reply) => match reply.0 {
|
||||
Ok(buf) => {
|
||||
slice::from_raw_parts_mut(data, (buf.0).len().min(length as usize))
|
||||
let len = (buf.0).len().min(length as usize);
|
||||
slice::from_raw_parts_mut(data, len)
|
||||
.copy_from_slice(buf.0);
|
||||
if !transferred.is_null() {
|
||||
*transferred = (buf.0).len() as c_int;
|
||||
*transferred = len as c_int;
|
||||
}
|
||||
LIBUSB_SUCCESS
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue