communicate' cmd ports serial = do
    when (cmd /= Status) $ mapM_ (\x -> send serial $ pack $ decideByteString cmd x) ports
    out <- mapM (queryStatus . decideByteString Status) ports
    return $ map (parseStatus . head . unpack) out
    where
        decideByteString cmd port = show $ fromEnum cmd + (fromEnum port) * 3
        queryStatus c = send serial (pack c) >> recv serial 1
communicate' cmd ports serial = do
    when (cmd /= Status) $ mapM_ (\x -> send serial $ pack $ decideByteString cmd x) ports
    out <- mapM (queryStatus . decideByteString Status) ports
    return $ map (parseStatus . head . unpack) out
    where
        decideByteString cmd port = show $ fromEnum cmd + (fromEnum port) * 3
        queryStatus c = send serial (pack c) >> recv serial 1
communicate' cmd ports serial = do
    when (cmd /= Status) $ mapM_ (\x -> send serial $ pack $ decideByteString cmd x) ports
    out <- mapM (queryStatus . decideByteString Status) ports
    return $ map (parseStatus . head . unpack) out
    where
        decideByteString cmd port = show $ fromEnum cmd + (fromEnum port) * 3
        queryStatus c = send serial (pack c) >> recv serial 1