Commit 17ef48 optionally dump TX/RX coms

3 files Authored and Committed by Richard Marko 2 years ago
optionally dump TX/RX coms

    
1 @@ -35,7 +35,7 @@
2   main = do
3     cfg@ESPCfg{..} <- execParser opts
4   
5 -   esp@ESP{..} <- newESP eHost ePort
6 +   esp@ESP{..} <- setVerbTX <$> newESP eHost ePort
7   
8     --async $ forever $ (atomically $ readTChan $ espOutChan) >>= dump
9     let waitOk e@ESP{..} = do
 1 @@ -26,6 +26,9 @@
 2   unsetSock :: ESP -> ESP
 3   unsetSock = \x -> x { espSock = Nothing }
 4   
 5 + setVerbTX :: ESP -> ESP
 6 + setVerbTX = \x -> x { espVerbTX = True }
 7 + 
 8   connectESP :: ESP -> IO ESP
 9   connectESP esp@ESP{..} = do
10     sock <- connectE (B.unpack espHost) (show espPort)
11 @@ -54,7 +57,10 @@
12               -- we should wait for '>' or use
13               -- rpc() on the client which responds
14               -- with ok/fail
15 -             B.putStrLn x
16 +             case espVerbTX of
17 +               True -> B.putStrLn x
18 +               False -> return ()
19 + 
20               threadDelay 200000
21               loop
22   
 1 @@ -39,6 +39,8 @@
 2     , espPort        :: Port
 3     , espInChan      :: TChan (Maybe B.ByteString)
 4     , espOutChan     :: TChan (Maybe B.ByteString)
 5 +   , espVerbTX      :: Bool
 6 +   , espVerbRX      :: Bool
 7     }
 8   
 9   data ESPLib = ESPLib {
10 @@ -61,6 +63,8 @@
11                , espPort = port
12                , espInChan = ic
13                , espOutChan = oc
14 +              , espVerbTX = False
15 +              , espVerbRX = False
16                }
17   
18