added data reply to camera handler, now only missing tmtcpy counterpart
This commit is contained in:
parent
88d4384beb
commit
09bef401c0
Binary file not shown.
@ -35,11 +35,14 @@ use satrs::hk::HkRequest;
|
|||||||
use satrs::request::{GenericMessage, MessageMetadata, UniqueApidTargetId};
|
use satrs::request::{GenericMessage, MessageMetadata, UniqueApidTargetId};
|
||||||
use satrs::tmtc::PacketAsVec;
|
use satrs::tmtc::PacketAsVec;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::process::Command;
|
use std::process::{Command, Output};
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
use satrs::pus::action::{ActionReplyPus, ActionReplyVariant};
|
use satrs::pus::action::{ActionReplyPus, ActionReplyVariant};
|
||||||
|
use satrs::pus::EcssTmtcError;
|
||||||
|
use crate::pus::action::send_data_reply;
|
||||||
|
|
||||||
const IMS_TESTAPP: &str = "scripts/ims100_testapp";
|
// const IMS_TESTAPP: &str = "scripts/ims100_testapp";
|
||||||
|
const IMS_TESTAPP: &str = "ims100_testapp";
|
||||||
|
|
||||||
const DEFAULT_SINGLE_CAM_PARAMS: CameraPictureParameters = CameraPictureParameters {
|
const DEFAULT_SINGLE_CAM_PARAMS: CameraPictureParameters = CameraPictureParameters {
|
||||||
R: 8,
|
R: 8,
|
||||||
@ -141,6 +144,7 @@ pub enum CameraError {
|
|||||||
DeserializeError,
|
DeserializeError,
|
||||||
ListFileError,
|
ListFileError,
|
||||||
IoError(std::io::Error),
|
IoError(std::io::Error),
|
||||||
|
EcssTmtcError(EcssTmtcError),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<std::io::Error> for CameraError {
|
impl From<std::io::Error> for CameraError {
|
||||||
@ -149,6 +153,12 @@ impl From<std::io::Error> for CameraError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<EcssTmtcError> for CameraError {
|
||||||
|
fn from(value: EcssTmtcError) -> Self {
|
||||||
|
Self::EcssTmtcError(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl fmt::Display for CameraError {
|
impl fmt::Display for CameraError {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
@ -170,6 +180,9 @@ impl fmt::Display for CameraError {
|
|||||||
CameraError::IoError(io_error) => {
|
CameraError::IoError(io_error) => {
|
||||||
write!(f, "{}", io_error)
|
write!(f, "{}", io_error)
|
||||||
}
|
}
|
||||||
|
CameraError::EcssTmtcError(ecss_tmtc_error) => {
|
||||||
|
write!(f ,"{}", ecss_tmtc_error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -276,12 +289,14 @@ impl IMS100BatchHandler {
|
|||||||
_ => return Err(CameraError::VariantNotImplemented),
|
_ => return Err(CameraError::VariantNotImplemented),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
self.take_picture(param)?;
|
let output = self.take_picture(param)?;
|
||||||
|
debug!("Sending action reply!");
|
||||||
|
send_data_reply(self.id, output.stdout, &self.stamp_helper, &self.tm_tx)?;
|
||||||
self.action_reply_tx.send(GenericMessage::new(*requestor_info, ActionReplyPus::new(action_request.action_id, ActionReplyVariant::Completed))).unwrap();
|
self.action_reply_tx.send(GenericMessage::new(*requestor_info, ActionReplyPus::new(action_request.action_id, ActionReplyVariant::Completed))).unwrap();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn take_picture(&mut self, param: CameraPictureParameters) -> Result<(), CameraError> {
|
pub fn take_picture(&mut self, param: CameraPictureParameters) -> Result<Output, CameraError> {
|
||||||
info!("Taking image!");
|
info!("Taking image!");
|
||||||
let mut cmd = Command::new(IMS_TESTAPP);
|
let mut cmd = Command::new(IMS_TESTAPP);
|
||||||
cmd.arg("-R")
|
cmd.arg("-R")
|
||||||
@ -305,12 +320,11 @@ impl IMS100BatchHandler {
|
|||||||
.arg(¶m.E.to_string())
|
.arg(¶m.E.to_string())
|
||||||
.arg("-w")
|
.arg("-w")
|
||||||
.arg(¶m.W.to_string());
|
.arg(¶m.W.to_string());
|
||||||
|
|
||||||
let output = cmd.output()?;
|
let output = cmd.output()?;
|
||||||
|
|
||||||
debug!("{}", String::from_utf8_lossy(&output.stdout));
|
debug!("Imager Output: {}", String::from_utf8_lossy(&output.stdout));
|
||||||
|
|
||||||
Ok(())
|
Ok(output)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn list_current_images(&self) -> Result<Vec<String>, CameraError> {
|
pub fn list_current_images(&self) -> Result<Vec<String>, CameraError> {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use log::{error, warn};
|
use log::{error, warn};
|
||||||
use ops_sat_rs::config::components::PUS_ACTION_SERVICE;
|
|
||||||
use ops_sat_rs::config::tmtc_err;
|
use ops_sat_rs::config::tmtc_err;
|
||||||
use satrs::action::{ActionRequest, ActionRequestVariant};
|
use satrs::action::{ActionRequest, ActionRequestVariant};
|
||||||
use satrs::params::WritableToBeBytes;
|
use satrs::params::WritableToBeBytes;
|
||||||
@ -10,17 +9,17 @@ use satrs::pus::verification::{
|
|||||||
FailParams, FailParamsWithStep, TcStateAccepted, TcStateStarted, VerificationReporter,
|
FailParams, FailParamsWithStep, TcStateAccepted, TcStateStarted, VerificationReporter,
|
||||||
VerificationReportingProvider, VerificationToken,
|
VerificationReportingProvider, VerificationToken,
|
||||||
};
|
};
|
||||||
use satrs::pus::{
|
use satrs::pus::{ActiveRequestProvider, EcssTcAndToken, EcssTcInVecConverter, EcssTmSender, EcssTmtcError, GenericConversionError, PusPacketHandlerResult, PusReplyHandler, PusServiceHelper, PusTcToRequestConverter, PusTmVariant};
|
||||||
ActiveRequestProvider, EcssTcAndToken, EcssTcInVecConverter, EcssTmSender, EcssTmtcError,
|
|
||||||
GenericConversionError, PusPacketHandlerResult, PusReplyHandler, PusServiceHelper,
|
|
||||||
PusTcToRequestConverter,
|
|
||||||
};
|
|
||||||
use satrs::request::{GenericMessage, UniqueApidTargetId};
|
use satrs::request::{GenericMessage, UniqueApidTargetId};
|
||||||
use satrs::spacepackets::ecss::tc::PusTcReader;
|
use satrs::spacepackets::ecss::tc::PusTcReader;
|
||||||
use satrs::spacepackets::ecss::{EcssEnumU16, PusPacket};
|
use satrs::spacepackets::ecss::{EcssEnumU16, PusPacket};
|
||||||
use satrs::tmtc::PacketAsVec;
|
use satrs::tmtc::PacketAsVec;
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
use satrs::spacepackets::ecss::tm::{PusTmCreator, PusTmSecondaryHeader};
|
||||||
|
use satrs::spacepackets::SpHeader;
|
||||||
|
use ops_sat_rs::config::components::PUS_ACTION_SERVICE;
|
||||||
|
use ops_sat_rs::TimeStampHelper;
|
||||||
|
|
||||||
use crate::requests::GenericRequestRouter;
|
use crate::requests::GenericRequestRouter;
|
||||||
|
|
||||||
@ -29,6 +28,8 @@ use super::{
|
|||||||
PusTargetedRequestService, TargetedPusService,
|
PusTargetedRequestService, TargetedPusService,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const DATA_REPLY: u8 = 130;
|
||||||
|
|
||||||
pub struct ActionReplyHandler {
|
pub struct ActionReplyHandler {
|
||||||
fail_data_buf: [u8; 128],
|
fail_data_buf: [u8; 128],
|
||||||
}
|
}
|
||||||
@ -270,6 +271,22 @@ impl TargetedPusService for ActionServiceWrapper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn send_data_reply<TmSender: EcssTmSender>(apid_target: UniqueApidTargetId, reply_data: Vec<u8>, stamp_helper: &TimeStampHelper, tm_sender: &TmSender) -> Result<(), EcssTmtcError> {
|
||||||
|
let sp_header = SpHeader::new_from_apid(apid_target.apid);
|
||||||
|
let sec_header = PusTmSecondaryHeader::new(8, DATA_REPLY, 0, 0, stamp_helper.stamp());
|
||||||
|
let mut data = Vec::new();
|
||||||
|
data.extend(apid_target.apid.to_be_bytes());
|
||||||
|
data.extend(apid_target.unique_id.to_be_bytes());
|
||||||
|
data.extend(reply_data);
|
||||||
|
let data_reply_tm = PusTmCreator::new(
|
||||||
|
sp_header,
|
||||||
|
sec_header,
|
||||||
|
&data,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
tm_sender.send_tm(apid_target.id(), PusTmVariant::Direct(data_reply_tm))
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use satrs::pus::test_util::{
|
use satrs::pus::test_util::{
|
||||||
|
Loading…
Reference in New Issue
Block a user