diff --git a/scripts/tc-ads-watch-10min.ps1 b/scripts/tc-ads-watch-10min.ps1 new file mode 100644 index 0000000..c206a3d --- /dev/null +++ b/scripts/tc-ads-watch-10min.ps1 @@ -0,0 +1,24 @@ +$ErrorActionPreference = 'Stop' +$adsDll = 'C:\Program Files (x86)\Beckhoff\TwinCAT\3.1\Components\Base\v170\TwinCAT.Ads.dll' +Add-Type -Path $adsDll +$c = New-Object TwinCAT.Ads.TcAdsClient +$c.Connect('169.254.176.217.1.1', 851) +function ReadSym($name, $type) { + $h = $c.CreateVariableHandle($name) + $v = $c.ReadAny($h, $type) + $c.DeleteVariableHandle($h) + return $v +} +$prev = $null +for ($k = 1; $k -le 10; $k++) { + $nc = ReadSym 'GVL_Sync.nCycles' ([uint64]) + $bs = ReadSym 'GVL_Sync.bSync' ([bool]) + $nrs = ReadSym 'GVL_Sync.nReturnedSeq' ([uint64]) + $nm = ReadSym 'GVL_Sync.nMismatch' ([int]) + $lag = [int64]$nc - [int64]$nrs + $delta = if ($null -ne $prev) { $nm - $prev } else { 0 } + $prev = $nm + Write-Host ("{0,2} nCycles={1,-8} lag={2,4} bSync={3} nMismatch={4} delta={5}" -f $k, $nc, $lag, $bs, $nm, $delta) + if ($k -lt 10) { Start-Sleep -Seconds 60 } +} +$c.Dispose() diff --git a/src/main.rs b/src/main.rs index 850ec54..911b28e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -758,8 +758,8 @@ async fn run(cfg: &Config) -> Result<(), Box> { // Async pipelined FPWR: two alternating leaked tx slots so the in-flight // write future can hold a 'static buffer while the response is reaped // at the start of the next cycle. - let tx_slot_a = Box::leak(Box::new([0u8; 8])); - let tx_slot_b = Box::leak(Box::new([0u8; 8])); + let tx_slot_a = Box::leak(Box::new([0u8; PAYLOAD_LEN])); + let tx_slot_b = Box::leak(Box::new([0u8; PAYLOAD_LEN])); let mut tx_slot_toggle = false; let mut pending_tx: Option< std::pin::Pin> + '_>>, @@ -939,7 +939,7 @@ async fn run(cfg: &Config) -> Result<(), Box> { tx_buf[264..268].copy_from_slice(&(jitter_ns as i32).to_le_bytes()); } - if spin_mode && PAYLOAD_LEN == 8 { + if spin_mode { // Async pipelined FPWR: kick the frame onto the wire now // (poll_once drives it to sendable), reap response next // cycle. Frees ~240us of blocking write time per cycle.