use crate::{DiagServerResult, DiagnosticServer};
use super::{UDSCommand, UdsDiagnosticServer};
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub enum UDSSessionType {
Default,
Programming,
Extended,
SafetySystem,
Other(u8),
}
impl From<UDSSessionType> for u8 {
fn from(from: UDSSessionType) -> u8 {
match &from {
UDSSessionType::Default => 0x01,
UDSSessionType::Programming => 0x02,
UDSSessionType::Extended => 0x03,
UDSSessionType::SafetySystem => 0x04,
&UDSSessionType::Other(x) => x,
}
}
}
impl UdsDiagnosticServer {
pub fn set_session_mode(&mut self, session_mode: UDSSessionType) -> DiagServerResult<()> {
self.execute_command_with_response(
UDSCommand::DiagnosticSessionControl,
&[session_mode.into()],
)
.map(|_| ())
}
}