Skip to content

Commit

Permalink
Merge pull request #23 from AgentRev/master
Browse files Browse the repository at this point in the history
Fixed Interface::send not working with candleLight devices
  • Loading branch information
ericevenchick authored Aug 25, 2024
2 parents a7f1171 + 0f5d7b5 commit 4dae9e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion driver/src/device/gsusb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,11 @@ impl HostFrame {
data.push(self.channel);
data.push(self.flags);
data.push(self.reserved);
data.extend_from_slice(&self.data);
if ((self.flags & GS_CAN_FLAG_FD) != 0 || self.can_dlc > 8) {
data.extend_from_slice(&self.data);
} else { // legacy gs_host_frame is limited to 8 bytes of data
data.extend_from_slice(&self.data[..8]);
}
data
}
}
5 changes: 3 additions & 2 deletions driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ pub struct Frame {
impl Frame {
fn data_as_array(&self) -> [u8; 64] {
let mut data = [0u8; 64];
data[..64].clone_from_slice(&self.data[..64]);
let len = std::cmp::min(self.data.len(), data.len());
data[..len].copy_from_slice(&self.data[..len]);
data
}
// convert to a frame format expected by the device
Expand All @@ -122,7 +123,7 @@ impl Frame {

HostFrame {
echo_id: 1,
flags: 0,
flags: if self.fd { GS_CAN_FLAG_FD } else { 0 },
reserved: 0,
can_id,
can_dlc: self.can_dlc,
Expand Down

0 comments on commit 4dae9e6

Please sign in to comment.