Skip to content
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

build(deps): update socketcan requirement from 1.7 to 2.0 #261

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion springql-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ reqwest = {version = "0.11", features = ["json", "blocking"], default-features =
once_cell = "1.8"
parking_lot = "0.12"
time = {version="0.3.9", features = ["formatting", "parsing", "macros"]}
socketcan = "1.7"
socketcan = "2.0"

[dev-dependencies]
springql-config = {version="0.18.0", features= ["toml"], path="../springql-config"}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file is part of https://github.com/SpringQL/SpringQL which is licensed under MIT OR Apache-2.0. See file LICENSE-MIT or LICENSE-APACHE for full license details.

use socketcan::CANFrame;
use socketcan::{CanFrame, EmbeddedFrame, Frame};

use crate::{
api::error::Result,
Expand All @@ -15,7 +15,7 @@ use crate::{
///
/// Immediately converted into `Row` on stream-engine boundary.
#[derive(Clone, Debug, new)]
pub struct CANFrameSourceRow(CANFrame);
pub struct CANFrameSourceRow(CanFrame);

impl CANFrameSourceRow {
/// # Failure
Expand All @@ -31,7 +31,7 @@ impl CANFrameSourceRow {
let can_frame = self.0;
let mut column_values = ColumnValues::default();

let can_id_value = SqlValue::NotNull(NnSqlValue::UnsignedInteger(can_frame.id()));
let can_id_value = SqlValue::NotNull(NnSqlValue::UnsignedInteger(can_frame.raw_id()));
column_values
.insert(ColumnName::new("can_id".to_string()), can_id_value)
.expect("can_id must not duplicate");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::time::Duration;

use anyhow::{anyhow, Context};
use socketcan::{CANFrame, CANSocket, ShouldRetry};
use socketcan::{CanFrame, CanSocket, EmbeddedFrame, Frame, ShouldRetry, Socket};

use crate::{
api::{
Expand All @@ -23,7 +23,7 @@
#[derive(Debug)]
pub(in crate::stream_engine) struct CANSourceReader {
interface: String,
can_socket: CANSocket,
can_socket: CanSocket,
}

impl SourceReader for CANSourceReader {
Expand All @@ -36,7 +36,7 @@

let interface = &options.interface;

let can_socket = CANSocket::open(interface)
let can_socket = CanSocket::open(interface)

Check warning on line 39 in springql-core/src/stream_engine/autonomous_executor/task/source_task/source_reader/can.rs

View check run for this annotation

Codecov / codecov/patch

springql-core/src/stream_engine/autonomous_executor/task/source_task/source_reader/can.rs#L39

Added line #L39 was not covered by tests
.context(format!(
"failed to open socket CAN interface {}",
&interface
Expand Down Expand Up @@ -92,22 +92,22 @@
}

impl CANSourceReader {
fn can_frame_into_row(&self, frame: CANFrame) -> Result<SourceRow> {
if frame.is_rtr() {
fn can_frame_into_row(&self, frame: CanFrame) -> Result<SourceRow> {
if frame.is_remote_frame() {

Check warning on line 96 in springql-core/src/stream_engine/autonomous_executor/task/source_task/source_reader/can.rs

View check run for this annotation

Codecov / codecov/patch

springql-core/src/stream_engine/autonomous_executor/task/source_task/source_reader/can.rs#L95-L96

Added lines #L95 - L96 were not covered by tests
unimplemented!("RTR (remote transmission request) frames are not supported");
} else if frame.is_extended() {
unimplemented!("Extended frame format is not supported");
} else if frame.is_error() {
} else if frame.is_error_frame() {

Check warning on line 100 in springql-core/src/stream_engine/autonomous_executor/task/source_task/source_reader/can.rs

View check run for this annotation

Codecov / codecov/patch

springql-core/src/stream_engine/autonomous_executor/task/source_task/source_reader/can.rs#L100

Added line #L100 was not covered by tests
Err(SpringError::ForeignIo {
source: anyhow!("got a error CAN frame (CAN ID: {})", frame.id()),
source: anyhow!("got a error CAN frame (CAN ID: {:?})", frame.id()),

Check warning on line 102 in springql-core/src/stream_engine/autonomous_executor/task/source_task/source_reader/can.rs

View check run for this annotation

Codecov / codecov/patch

springql-core/src/stream_engine/autonomous_executor/task/source_task/source_reader/can.rs#L102

Added line #L102 was not covered by tests
foreign_info: ForeignInfo::SocketCAN(self.interface.clone()),
})
} else {
Ok(Self::_can_frame_into_row(frame))
}
}

fn _can_frame_into_row(frame: CANFrame) -> SourceRow {
fn _can_frame_into_row(frame: CanFrame) -> SourceRow {
SourceRow::CANFrame(CANFrameSourceRow::new(frame))
}
}
Expand All @@ -116,6 +116,7 @@
mod tests {

use crate::stream_engine::{autonomous_executor::row::SchemalessRow, SqlValue};
use socketcan::ExtendedId;

use super::*;

Expand All @@ -124,7 +125,7 @@
let can_id = 1;
let can_data = &[0x00u8, 0x01];

let frame = CANFrame::new(can_id, can_data, false, false).unwrap();
let frame = CanFrame::new(ExtendedId::new(can_id).unwrap(), can_data).unwrap();
let source_row = CANSourceReader::_can_frame_into_row(frame);
let row = SchemalessRow::try_from(source_row).unwrap();

Expand Down