1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
//! # XVC Protocol Library
//!
//! This crate provides a Rust implementation of the [Xilinx Virtual Cable (XVC)](https://github.com/Xilinx/XilinxVirtualCable) protocol,
//! enabling client-server communication for JTAG vector shifting and cable configuration.
//!
//! ## Overview
//!
//! XVC is a protocol used by Xilinx design tools to interact with FPGA devices over a network connection.
//! This library implements the protocol specification, allowing you to:
//!
//! - Serialize and deserialize XVC protocol messages
//! - Exchange JTAG vectors with an XVC server
//! - Configure TCK (Test Clock) timing parameters
//! - Query server capabilities and protocol version information
//!
//! ## Protocol Features
//!
//! - **Protocol Versions**: XVC 1.0
//! - **Message Types**:
//! - `GetInfo`: Query server capabilities (protocol version, max vector length)
//! - `SetTck`: Configure the TCK clock period in nanoseconds
//! - `Shift`: Shift JTAG TMS/TDI vectors into a device
//!
//! ## Basic Usage
//!
//! ### Reading Messages from a Server
//!
//! ```
//! use xvc_protocol::{Message, XvcInfo, Version};
//! use std::io::Cursor;
//!
//! // Read server capabilities
//! let server_response = b"xvcServer_v1.0:32\n";
//! let mut reader = Cursor::new(server_response);
//! let info = XvcInfo::from_reader(&mut reader).expect("Info should parse");
//! assert_eq!(info.version(), Version::V1_0);
//! assert_eq!(info.max_vector_len(), 32);
//! ```
//!
//! ### Writing Messages to a Server
//!
//! ```
//! use xvc_protocol::BorrowedMessage;
//! use std::vec::Vec;
//!
//! // Request server info
//! let msg = BorrowedMessage::GetInfo;
//! let mut buffer = Vec::new();
//! msg.write_to(&mut buffer).expect("Writing to vector shouldn't fail");
//! // Send buffer to server...
//! assert_eq!(buffer, b"getinfo:");
//! ```
//!
//! ### Shifting JTAG Vectors
//!
//! ```
//! use xvc_protocol::BorrowedMessage;
//!
//! let num_bytes = 2;
//! let tms = vec![0xAA; num_bytes];
//! let tdi = vec![0x55; num_bytes];
//!
//! let shift_msg = BorrowedMessage::Shift { num_bits: 2 * num_bytes as u32, tms: &tms, tdi: &tdi };
//! let mut output = Vec::new();
//! shift_msg.write_to(&mut output).expect("Writing to vector shouldn't fail");
//! assert_eq!(output, b"shift:\x04\x00\x00\x00\xAA\xAA\x55\x55");
//! ```
//!
//! ## Message Format
//!
//! All messages use a binary protocol with the following structure:
//!
//! - **GetInfo**: `getinfo:`
//! - **SetTck**: `settck:<period in ns: u32>`
//! - **Shift**: `shift:<num_bits: u32><TMS vector><TDI vector>`
//! - **XvcInfo**: `xvcServer_v{version}:<max_vector_len: u32>\n`
//!
//! ## Error Handling
//!
//! This library uses the [`error::ReadError`] type for protocol parsing errors.
//!
//! ## Thread Safety
//!
//! The types in this library are thread-safe and can be safely shared across threads.
//! However, I/O operations (reading/writing) are not synchronized and require external coordination.
pub use *;
pub