Open main menu

Changes

m
*The detector silently drops any packet with a SeqId it has already processed, so never reuse one.
== Script Download ==
 
The detector does not have fixed acquisition commands. Instead the host
downloads small programs, called scripts, that the detector stores by ID and
then runs on command. A script is a sequence of primitive operations: program
the ROE (readout electronics) registers, wait, acquire an image, signal an
event. The acquisition behavior of the panel is defined entirely by these
downloaded scripts, which are taken from the application mode XML files (for
example IDC_URP_SE_2200.xml for single energy, 2048 by 2048).
 
=== The GENERIC_SCRIPT command ===
 
A script is sent to the detector with the GENERIC_SCRIPT command, cmd_type 5.
The wire format is:
 
[cmd_type : 4 LE] = 5
[length : 4 LE] = 8 + sum(command sizes) + 2
[script header : 8 bytes]
[packed command 1]
[packed command 2]
...
[terminator : 2 bytes] = 00 00
 
The 8 byte script header is:
 
{| class="wikitable"
! Offset !! Size !! Field !! Meaning
|-
| 0 || 2 LE || scriptID || the slot the script is stored in
|-
| 2 || 2 LE || repeatCount || 0 = run once, 65535 = loop forever
|-
| 4 || 4 LE || repeatEvent || event ID that breaks an infinite loop (0 if unused)
|}
 
Note: the application mode XML lists a fourth header value, ROEdata. This is a
substitution source for the script's commands, not a field on the wire. The wire
header is exactly 8 bytes.
 
=== Packed command primitives ===
 
Each command inside the script starts with a one byte DETECTORCODE that selects
its type and length:
 
{| class="wikitable"
! DETECTORCODE !! Command !! Size !! Layout (after the code byte)
|-
| 1 || Acquisition || 17 || typeMode:1, imageId:1, noScrubs:1, scrubDuration:4 LE, maxExposeTime:4 LE, tailTime:4 LE, transferMode:1
|-
| 2 || ROE command || 14 || responseFlag:1, timerValue:4 LE, roeCmd:4 LE, roeData:4 LE
|-
| 3 || Send host event || 5 || eventId:4 LE
|-
| 4 || Wait for host event || 9 || eventId:4 LE, timeout:4 LE
|-
| 5 || Delay || 5 || delayMicroseconds:4 LE
|}
 
For example, a ROE command sets a readout register (roeCmd, roeData) and an
Acquisition command triggers the actual exposure window and image readout.
 
=== Download sequence ===
 
# The host sends the GENERIC_SCRIPT packet for a given scriptID.
# The detector replies with a bare acknowledgement carrying the same sequence ID. (It may also send a GENERIC_SCRIPT status reply with a status byte; status 0 means accepted.)
# The host repeats this for each script it wants resident on the detector.
# When ready, the host sends EXECUTE_SCRIPT, cmd_type 6, which runs the stored scripts. During and after execution the detector sends status notifications, and finally EXECUTION_COMPLETE, cmd_type 0x10000.
 
Scripts are persistent for the session: once downloaded they can be executed
without resending.
 
=== The standard script set ===
 
The single energy mode downloads four scripts in order. The scriptID in the
header is the slot; the XML refers to them by a separate DETECTOR_SCRIPT_ID.
 
{| class="wikitable"
! scriptID !! Purpose !! Notes
|-
| 7 || ROE initialization || Scan setup plus a sequence of zero pulses, ends by sending host event 17
|-
| 8 || Standby loop || repeatCount 65535, broken by event 41; keeps the panel idle between acquisitions
|-
| 0 || Standard acquisition || Requires a real X-ray exposure to complete
|-
| 1 || Dark / offset acquisition || Completes with no X-ray; used to test the full flow
|}
 
For a no X-ray test, download script 7 then script 1 and execute. The detector
runs the ROE init, performs the dark acquisition, and reports
EXECUTION_COMPLETE in a few seconds.
 
=== Inspecting the encoded scripts ===
See [[#Main test py script: Usage and Parameters|Main test py script]]
The exact wire bytes of every built script can be printed without touching the
detector:
 
python flashpad_acquire.py --dump-scripts
 
This shows the full GENERIC_SCRIPT encoding (header, packed commands, and
terminator) as hex, which is useful for verifying the format against the XML.
==Sensor Readout and Host Registration==