start TM handling for TCP client
This commit is contained in:
parent
b359ff9d33
commit
b5e048a13b
@ -30,6 +30,7 @@ pub struct TcpSppClient {
|
||||
events: Events,
|
||||
client: TcpStream,
|
||||
read_buf: [u8; 4096],
|
||||
tm_tcp_client_rx: mpsc::Receiver<PacketAsVec>,
|
||||
tc_source_tx: mpsc::Sender<PacketAsVec>,
|
||||
validator: SimpleSpValidator,
|
||||
}
|
||||
@ -38,6 +39,7 @@ impl TcpSppClient {
|
||||
pub fn new(
|
||||
id: ComponentId,
|
||||
tc_source_tx: mpsc::Sender<PacketAsVec>,
|
||||
tm_tcp_client_rx: mpsc::Receiver<PacketAsVec>,
|
||||
valid_ids: &'static [PacketId],
|
||||
) -> io::Result<Self> {
|
||||
let poll = Poll::new()?;
|
||||
@ -55,6 +57,7 @@ impl TcpSppClient {
|
||||
events,
|
||||
client,
|
||||
read_buf: [0; 4096],
|
||||
tm_tcp_client_rx,
|
||||
tc_source_tx,
|
||||
validator: SimpleSpValidator::new(TcpComponent::Client, valid_ids.to_vec()),
|
||||
})
|
||||
|
@ -47,6 +47,7 @@ fn main() {
|
||||
let (tc_source_tx, tc_source_rx) = mpsc::channel();
|
||||
let (tm_funnel_tx, tm_funnel_rx) = mpsc::channel();
|
||||
let (tm_server_tx, tm_server_rx) = mpsc::channel();
|
||||
let (tm_tcp_client_tx, tm_tcp_client_rx) = mpsc::channel();
|
||||
|
||||
let (pus_test_tx, pus_test_rx) = mpsc::channel();
|
||||
// let (pus_event_tx, pus_event_rx) = mpsc::channel();
|
||||
@ -162,8 +163,12 @@ fn main() {
|
||||
stop_signal.clone(),
|
||||
);
|
||||
|
||||
let mut tcp_spp_client =
|
||||
TcpSppClient::new(TCP_SPP_CLIENT.id(), tc_source_tx, VALID_PACKET_ID_LIST)
|
||||
let mut tcp_spp_client = TcpSppClient::new(
|
||||
TCP_SPP_CLIENT.id(),
|
||||
tc_source_tx,
|
||||
tm_tcp_client_rx,
|
||||
VALID_PACKET_ID_LIST,
|
||||
)
|
||||
.expect("creating TCP SPP client failed");
|
||||
|
||||
info!("Starting CTRL task");
|
||||
|
@ -77,7 +77,8 @@ impl TmFunnelCommon {
|
||||
pub struct TmFunnelDynamic {
|
||||
common: TmFunnelCommon,
|
||||
tm_funnel_rx: mpsc::Receiver<PacketAsVec>,
|
||||
tm_server_tx: mpsc::Sender<PacketAsVec>,
|
||||
tm_udp_server_tx: mpsc::Sender<PacketAsVec>,
|
||||
tm_tcp_client_tx: mpsc::Sender<PacketAsVec>,
|
||||
stop_signal: Arc<AtomicBool>,
|
||||
}
|
||||
|
||||
@ -85,13 +86,15 @@ impl TmFunnelDynamic {
|
||||
pub fn new(
|
||||
sync_tm_tcp_source: SyncTcpTmSource,
|
||||
tm_funnel_rx: mpsc::Receiver<PacketAsVec>,
|
||||
tm_server_tx: mpsc::Sender<PacketAsVec>,
|
||||
tm_udp_server_tx: mpsc::Sender<PacketAsVec>,
|
||||
tm_tcp_client_tx: mpsc::Sender<PacketAsVec>,
|
||||
stop_signal: Arc<AtomicBool>,
|
||||
) -> Self {
|
||||
Self {
|
||||
common: TmFunnelCommon::new(sync_tm_tcp_source),
|
||||
tm_funnel_rx,
|
||||
tm_server_tx,
|
||||
tm_udp_server_tx,
|
||||
tm_tcp_client_tx,
|
||||
stop_signal,
|
||||
}
|
||||
}
|
||||
@ -110,9 +113,14 @@ impl TmFunnelDynamic {
|
||||
.expect("Creating TM zero copy writer failed");
|
||||
self.common.apply_packet_processing(zero_copy_writer);
|
||||
self.common.sync_tm_tcp_source.add_tm(&tm.packet);
|
||||
self.tm_server_tx
|
||||
.send(tm)
|
||||
.expect("Sending TM to server failed");
|
||||
let result = self.tm_udp_server_tx.send(tm);
|
||||
if result.is_err() {
|
||||
log::error!("TM UDP server has disconnected");
|
||||
}
|
||||
let result = self.tm_tcp_client_tx.send(tm);
|
||||
if result.is_err() {
|
||||
log::error!("TM TCP client has disconnected");
|
||||
}
|
||||
if self.stop_signal.load(std::sync::atomic::Ordering::Relaxed) {
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user