Service Mode Programming

== Purpose ==
Service Mode is meant for use in customizing and testing DCC decoders. 
* It is recommended that Service Mode Programming use an isolated programming track
* External loads such as smoke generators, sound generators, constant lighting, energy storage modules, etc., be disconnected during programming. Decoders should turn such loads off upon entry to service mode
*The programming environment should limit the available energy during programming to prevent damage S 9.2.3 Service Mode operations should be performed in an environment with limited energy to prevent damage to decoders during programming. For the purposes of this STANDARD, limited energy is defined as 250 mA, sustained for more than 100 ms. A programmer may further limit the energy via a current limiting resistor, if it is clearly documented that not all compatible DCC devices may be programmed by this programmer. 
A Programmer is a device used to program decoders under these conditions. It may be an external device, or incorporated into the command station.
=== Modes ===
In Service Mode Programming, the following modes are available: S-9.2.3: Service Mode supports four different methods for access to Configuration Variables (CVs): Direct Configuration, Address-Only, Physical Register, and Paged Addressing. The Service Mode instruction packet sequences are defined from a Command Station/Programmer perspective. 
# Basic Mode
## Address 
# Advanced Modes
## Physical Register (PH)
## Paged (PG)
## Direct (PD)
Most decoders today support the Direct Mode. Many command stations support all these modes to maintain backward compatibility. Be sure to use the proper mode for your decoder.
=== Modes Required by the NMRA DCC Standard ===
 As of August 2002, Command Stations and Programmers submitted for conformance must implement Direct Mode. 
To conform to the NMRA Standards, manufacturers must implement one of the following programming methods:
# Address Only Programmers
#* Program CV #1 (Primary Address) using Address-Only Mode
# Register-Mode CV Programmers
#* Able to program a selected subset of CVs using Physical Register. Subset must include setting CV1 (primary address) with Address Only Mode. Must be clearly defined and documented.
# Paged CV Programmers S-9.2.3: For backward compatibility with decoders produced prior to August 2002 which do not support direct mode, support for paged mode is strongly encouraged by the NMRA. 
#* Ability to program selected subsets of CVs via Physical Register and Paged Addressing, Subset must include setting CV1 (primary address) with Address Only Mode. Must be clearly defined and documented.
# Direct CV Programmers
#* Program selected subset of CVs via Physical Register and Direct Addressing. Subset must include setting CV1 (primary address) with Address Only Mode. Must be clearly defined and documented.
# Universal CV Programmers
#* Have the ability to read and write a subset of CVs via Direct, Physical Register and Paged Addressing. Subset must include setting CV1 (primary address) with Address Only Mode. Must be clearly defined and documented.
=== Address Mode ===
The most basic Service Mode programming technique, where the decoder is instructed to change its Primary Address. 
Being able to specify the decoder's address allows even the most basic of command stations to control the most complex decoders. Basic DCC systems may ask you to specify which throttle you want to use, and set the decoder accordingly. 
A sophisticated DCC system will ask you what number you want to use as the address, and write that to the decoder. Most modellers use the locomotive's number as the address to simplify selecting a locomotive.
Address Mode can only read, or verify one register or CV, such as CV #1, the Primary Address.
=== Advanced Modes ===
Register Mode Programming - DCCWiki.com	Register Mode Programming - DCCWiki.com
Register 	Purpose
1 	Address
2 	Start Voltage
3 	Acceleration
4 	Deceleration/Braking
5 	Basic Configuration: Speed steps, Direction of Travel
6 	Offset, Reserved for use during Paged Mode
7 	Manufacturer ID
==== Physical Register Mode ====
Physical Register Mode is an obsolete method of programming which is not used in current decoders. Some decoders support this mode for legacy reasons. 
Early DCC decoders possessed a limited number of registers to configure the decoder.
:This mode allows you to program a decoder no matter what state it is in. You do not even need to know the address (hence the danger of programming all your decoders at once). It will also work if the decoder's memory is corrupted.
Physical Register Mode expands on the Address Mode, allowing another seven memory locations (registers) to be accessed. It is an early mode which only allows limited decoder programming.
For a multifunction decoder the registers shown in the table are available.
==== Paged Mode ====
As multifunction decoders became more sophisticated, the registers available expanded to a full set of 1024. A method was required to to address these additional registers. Paged Mode is the most commonly used programming mode and is the preferred method.
Paged Mode introduced the term "CV" (Configuration Variable). When Paged Mode is used, Register 6 becomes an offset pointer.
Should register 6 be set to a value of 1, there will be no offset, and registers 1 through 4 remain as is. If the offset pointer is set to a value of 2, registers 1 through 4 will now point to registers 5 through 8. As the offset is increased, the pointers will change accordingly. Not all decoders support this mode, avoid using Paged Mode unless the decoder supports it. The command station should be able to determine if the decoder will support Paged Mode.
To avoid this complex scenario, the software in most command stations hide this from the user. The command station asks for a CV number and performs the complex offset calculations to complete the programming process. While Paged Mode is similar to the Direct CV Mode, it is really a modified form of Register Mode which is slower.
 Do not remove the locomotive from the programming track until the programming process has completed. Doing so may prevent older command stations from being able to reprogram the decoder at a later date.
==== Reading a Decoder in Paged Mode ====
Paged Mode queries the decoder with "Does CVx have a value of Y?" It continues to increment the value of Y until the decoder acknowledges the value matches the contents of the specified CV. There are only two states: NACK (Not Acknowledge), where the command station times out waiting for a response, or ACK (acknowledge), where the decoder responds. This method can take a long time to read the CV settings of a decoder, as it must step through up to 256 (0,1, 2, 3, 4...... 255) possible combinations.
 Paged Mode can be problematic with some DCC Systems. Direct Mode is a better choice, especially with modern decoders. Direct Mode can be up to sixteen times faster than Paged Mode. 
==== Direct CV Programming Mode ====
* Direct Mode is another mode allowed by the NMRA DCC Recommended Practices.
* Direct Mode is the fastest and most recent mode of programming. Most, if not all decoders made in the past 20 years support this mode.
* Sometimes called Direct Bit Mode
Direct Mode allows writing of individual bits. A CV has up to 256 (28) possible states. In the early days of DCC, with the limited number of registers and their possible values, reading the value of a register was slow, but acceptable. As the number of registers and their possible values increased, the time required increased. 
==== Reading CVs in Direct Mode ====
Direct Mode is similar to Paged Mode, except when querying a decoder Direct mode asks "Does Bit 'X' of CVx = 1?" It is much faster, as it can read an eight-bit CV with 8 queries instead of a possible 256 reads required by Paged Mode. The command station can then calculate from those responses what the content of CVx is. In the worst case the command station will have to wait for 8 timeouts to occur, or 9 to determine no reply.
The command station will then follow up with a full byte verification to ensure no mistakes occurred. This mode can be up to 50 times faster than the other methods available. With modern decoders, such as the ESU LokSound's 100,000 plus CVs, this makes a difference. 
*Direct Mode is the preferred method with ESU decoders, and is much faster.
** If you have a number of ESU decoders, a LokProgrammer is recommended. It is much faster when reading and writing CVs as it uses a proprietary technique.
=== Service Mode Programming Environment ===
==== Broadcast Packets ====
Programming instructions are broadcast to all multifunction decoders on the track, and every decoder will accept the instructions. This method is dangerous as it will reprogram every multifunction decoder in every vehicle on the layout. It is very easy to make a mistake and set every vehicle to the same address. 
This is the reason for the isolated programming track.
==== Programming Track ====
A programming track is either a dedicated length of track located off the layout or a section of track on the layout which is electrically isolated from the rest of the layout. The booster's programming track outputs connect to it for Service Mode programming. Only the vehicle on the programming track will be programmed. 
In this environment, the broadcast packets only go to one decoder. The program track is supplied with a low current. This avoids the possibility of wiring error damaging a decoder. Many decoder manufacturers will recommend programming only on a programming track for this reason.
 As programming packets are only present for fractions of a second, it is not possible to measure voltage present on the rails or at the Program Track outputs. There are no signals present unless a programming operation is in progress.
==== Safe Mode Programming ====
Many DCC systems make further attempts to protect a decoder during programming.
To prevent damage should a decoder be wiring incorrectly, a regulated Low Current source is used for programming purposes. In addition, the programming track is only active during programming. At any other time, it will have no power. 
The purpose of Service Mode is to allow Customization and testing of decoders.
===Service Mode Programming ===
Service Mode operations should be done on an isolated programming track.
 An isolated programming track is essential when using Service Mode programming, as the command station sends a broadcast message to all decoders on the track. If you did not use a programming track, you would essentially reprogram all your decoders, something you most likely do not want to do. By using a programming track, you isolate, or select, the decoder you want (re)program. 
* External loads, such as constant lighting, smoke generators and other loads should be switched off. Decoders should shut down any loads connected to them when they enter service mode.
* Service mode operations should take place in a limited power environment. The NMRA specifies no more than 250mA for 100mS. The maximum current may be limited by the programmer using a resistor, but the manufacturer must state that it may not be 100% DCC compatible.
* Decoders equipped with capacitors, such as "keep-alive devices may pose problems. If possible, they should be disconnected prior to programming operations.
** A programming track booster may be required for some sound decoders.
;A Program Track connection may or may not be part of the command station/booster. Boosters which do not have additional connections for the program track use Service Mode on the layout via the track power connection.
====Entry and Exit from Service Mode====
A decoder is required to enter Service Mode when it receives a Reset Packet followed by a Service Mode packet. The purpose of the reset packets is to wake up the decoder and provide it the energy needed to power up prior to the transmission of programming information. Section C, S 9.2.3 Digital Decoder Entry to and Exit from Service Mode 
It cannot act on service mode packets when not in service mode.
The decoder will exit Service Mode, but not enter Operations Mode if:
#A non-service mode instruction packet is successfully received 
# Twenty milliseconds have passed since the last valid reset or service mode instruction packet was received 
After exiting service mode, the decoder will only re-enter operations mode when it receives a valid operations mode packet that is different from the previous service mode instruction packet. This is done to prevent execution of service mode packets as operations mode packets.
:Service Mode instruction packets have a short address in the range of decimal 112 to 127.
==== CV Readback ====
Service Mode also includes a CV Readback capability. The decoder can be read and its settings determined. Not all command stations support readback. 
====Service Mode Instruction Packets====
;Bits are numbered right to left, Bit 0 is the rightmost bit and the Least Significant Bit.
* Long Preamble: The packet will have a preamble of at least 20 bits, to allow the decoder time to process the instructions. - In Service Mode the Command Station/Programmer will increase the preamble of the packet from 75 the minimum (per S9.2) to at least 20 bits to allow extra time for the Digital Decoder to process the packets. 
* Power On Cycle: After applying power to the track, the programmer will send at least 20 valid packets before service mode operations commence. This allows the decoder to power up and stabilize. During this time a current draw greater than 250mA lasting more than 100mS after initialization of packet transmissions is considered a fault condition. A decoder should not draw more than 100mA of current, except when processing an acknowledgement. Upon applying power to the track, the Command Station/Programmer must transmit at least 20 valid packets to the Digital Decoder to allow it time to stabilize internal operation before any Service Mode operations are initiated. During the initial decoder power-up sequence, a current load of greater than 250 mA sustained after 100 milliseconds (ms) of initiation of packet transmission should be interpreted as an over-current fault condition for the decoder being programmed. After the power-up sequence, a decoder with all outputs turned off (i.e. lamps, amplifiers, etc.) shall not draw more than 100 mA of current except for when processing an acknowledgment. 
===Decoder Acknowledgement===
There is an acknowledgement (ACK) mechanism specified. This allows the decoder to act on instructions regardless of the ability of the programmer to detect the ACK signal. 
There are two acknowledgement mechanisms defined:
# Basic
# Advanced
====Basic====
This is defined by the decoder providing an increased load on the programming track, of at least 60mA for 6mS. One method is to apply power to the motor, or a similar load connected to the decoder. Many decoders apply a short burst of power to the motor, causing the locomotive to lurch forward. Basic acknowledgment is defined by the Digital Decoder providing an increased load (positive-delta) on the programming track of at least 60 mA for 6 ms +/-1 ms. It is permissible to provide this increased load by applying power to the motor or other similar device controlled by the Digital Decoder. ESU LokSound V5 and its related multifunction decoders alternate the direction on the motor for each acknowledgement. The result is the vehicle does not move significantly in any direction.
====Advanced====
Covered by NMRA Standards S-9.3.1 (obsolete) and 9.3.2 See-S-9.3.1 and S-9.3.2. 
===Timing===
The decoder should not send an ACK pulse until all the CV bits have been written into non-volatile memory.
The programmer should scan for the pulse after the end bit of the second service mode instruction packet, or as many packets as needed to send the instructions, as well as the specified decoder recovery time. The programmer must continue to send packets to the programming track (which turns supplies power to the decoder) until the end of the decoder recovery time.
Category: Multifunction Decoder
Category:Programming
== Packet Formats ==
Bits are labelled Left to Right, with the rightmost being the LSB (Least Significant Bit) "Bit 0", the leftmost being the MSB (Most Significant Bit), "Bit 7".
Abbreviations, Service Mode Programming	Abbreviations, Service Mode Programming
0 	Bit having a value of Zero
1 	Bit having a value of one
A 	CV Address
C 	Instruction Type
K 	Instruction Type
R 	Register Number
B 	Bit Position
D 	Data to be read or written
E 	Error Detection Bit The last data byte is used for error correction with both 3 and 4 byte data packets.
[ ] 	Sequences contained with the braces may be repeated, and nested one or more times as required.
# Long Preamble: When switching to Service Mode, the Programmer 'Programmer" may refer a Command Station or an external device used for programming purposes. shall increase the number of preamble bits to at least 20 from the minimum S-9.2 to allow the decoder time to process the packets.
# Power On Cycle: The Programmer must, upon applying track power. transmit at least 20 valid packets to the decoder, allowing time to stabilize any internal operations prior to the initiation of Service Mode Programming. A current draw greater than 250mA sustained over a 100mS period after initiating a packet transmission sequence shall be interpreted as an Over Current Fault Condition. After Power Up all functions shall be turned off and the decoder shall not draw more than 100mA of current, with the exception of an Acknowledgment being processed.
# Decoder Recovery Time: The Programmer shall send the same service mode or reset packets during this period until a specified packet time has been met or a valid acknowledgement has been received by the Programmer
# Reset Packet: Defined as a Broadcast Decoder Reset Packet which is valid for all decoders. S-9.2
# Hard Reset Cycle: A Hard Reset RP-9.2.1 followed by ten idle or reset packets. Used when the programmer desires to reset the decoder to its initial defined state.
# Page Reset Instruction: A packet sequence transmitted to ensure the content of a page register. This instruction may not have the desired effect with all older accessory decoders. 
=== Direct Mode ===
Direct Mode service mode instruction packets support accessing Configuration Variables by their configuration variable number RP-9.2.2 . 
Example: To determine if a decoder supports Direct Configuration Variable Addressing, the Programmer should perform two bit verifies, one verify for a bit value of ‘0’, one verify for a bit value of ‘1’ to the most significant bit within CV #8 (Manufacturer’s ID). Acknowledgment of either bit-verify indicates that the decoder fully supports all modes of Direct Configuration Variable Addressing (Verify Byte, Write Byte, & Bit Manipulation). A Command Station, Programmer, or Decoder, which supports Direct Mode, must implement all three instruction-types. 
Packet Sequence, Using Direct Mode 	Packet Sequence, Using Direct Mode
Power On Cycle, (Optional) 	Power On Cycle, (Optional)
[Three or more Reset Packets 	[Three or more Reset Packets
[ Five or more Verify packets to a single CV, (1-1023), followed by 1 or more Reset Packets if an acknowledgement is detected	Or 5 or more Writes to a single CV 1-1023
] 	
 	6 or more Identical Write or Reset packets (Decoder Recovery-Time) ]
Power-Off (Optional) 	Power-Off (Optional)
Within a verify or write sequence, the Programmer may cease sending packets and continue to the next step in the sequence when either a decoder acknowledgment is successfully received or the specified number of packets to be transmitted has completed 
CV Direct Addressing Instruction Packet	CV Direct Addressing Instruction Packet	CV Direct Addressing Instruction Packet 	CV Direct Addressing Instruction Packet	CV Direct Addressing Instruction Packet	CV Direct Addressing Instruction Packet	CV Direct Addressing Instruction Packet	CV Direct Addressing Instruction Packet	CV Direct Addressing Instruction Packet	CV Direct Addressing Instruction Packet
Long Preamble 	0 	0111CCAA 	0 	AAAAAAAA 	0 	DDDDDDDD 	0 	EEEEEEEE 	1
 	 	Instruction Type /CV Address The CV address is defined using a 10 bit number, the first two bits (AA) in the first byte are the most significant bits. The CV number is equal to the value of the 10 bits + 1. CV1= 00 0000000. The programmer must provide full read and write manipulation for all values of eight bit data.	 	Cv Address 	 	Data 	 	Error Bits 	
Instruction Types (CC)	Instruction Types (CC)
10 	Bit Manipulation
01 	Verify Byte
11 	Write Byte
==== Verify CV Byte ====
This instruction is used to compare the contents of the specified CV against the transmitted data. If identical, the decoder will send an ACK.
==== Write CV Byte ====
This instruction causes the data byte to be written into the CV address specified within the packet
==== CV Bit Manipulation ====
The Bit Manipulation instructions in Direct Address mode use a special format for the Data byte.
CV Direct Addressing Instruction Packet	CV Direct Addressing Instruction Packet	CV Direct Addressing Instruction Packet	CV Direct Addressing Instruction Packet	CV Direct Addressing Instruction Packet	CV Direct Addressing Instruction Packet	CV Direct Addressing Instruction Packet	CV Direct Addressing Instruction Packet	CV Direct Addressing Instruction Packet	CV Direct Addressing Instruction Packet
Long Preamble 	0 	0111CCAA 	0 	AAAAAAAA 	0 	111KDBBB 	0 	EEEEEEEE 	1
 	 	Instruction Type /CV Address 	 	Cv Address 	 	Data 	 	Error Bits 	
* BBB indicates bit position, where 0 = 000
* D is the value of the bit to be written
* K signifies a Write Command if equal to 1, or Verify if a value of 0.
=== Address Mode ===
Address-only service mode instruction packets support access to Configuration Variable #1 (Primary Address). When a new primary address is written using any method, a decoder must reset the extended addressing bit in the CV29) to value of ‘0’, and clear the consist address CV19.
Packet Sequence for Programmers using Address Mode 	Packet Sequence for Programmers using Address Mode
Power On Cycle (Optional) 	Power On Cycle (Optional)
Three or more Reset Packets 	Three or more Reset Packets
Five or more Page Reset Packets 	Five or more Page Reset Packets
Six or more Page Preset or Rest packets (Decoder-Recovery-Time from write to Page Register)	Six or more Page Preset or Rest packets (Decoder-Recovery-Time from write to Page Register)
Power OFF followed by Power ON Cycle (Optional) 	Power OFF followed by Power ON Cycle (Optional)
[Three or more Reset Packets 	[Three or more Reset Packets
[ Five or more verifications of CV1 	Or five or more Writes to CV1
] 	10 or more identical Write or Reset packets (Decoder-Recovery-Time)]
Power Off (Optional) 	Power Off (Optional)
Address Mode Packet 	Address Mode Packet 	Address Mode Packet 	Address Mode Packet 	Address Mode Packet 	Address Mode Packet 	Address Mode Packet 	Address Mode Packet
Long Preamble 	0 	0111C000 	0 	0DDDDDDD 	0 	EEEEEEEE 	1
In Address Mode Two Instruction (C) types are defined:	In Address Mode Two Instruction (C) types are defined:	In Address Mode Two Instruction (C) types are defined:	In Address Mode Two Instruction (C) types are defined:	In Address Mode Two Instruction (C) types are defined:	In Address Mode Two Instruction (C) types are defined:	In Address Mode Two Instruction (C) types are defined:	In Address Mode Two Instruction (C) types are defined:
 	 	C=0 	C=0 	Verify Address 	Verify Address 	Verify Address 	Verify Address
 	 	C=1 	C=1 	Write Address 	Write Address 	Write Address 	Write Address
* Verify Address Contents: The programmer compares the value of 0DDDDDDD to the contents of CV1. If they match an ACK is generated by the decoder.
* Write Address Contents: This instruction initiates a Write operation which stores the value of 0DDDDDDD in CV1, thus setting the Primary Address. The decoder may respond with an ACK.
=== Physical Register Mode ===
Packet Sequence for Physical Register Mode Addressing 	Packet Sequence for Physical Register Mode Addressing
Power On Cycle, if required (Optional) 	Power On Cycle, if required (Optional)
Three or more Reset Packets 	Three or more Reset Packets
Five or more writes to the Page Register 	Five or more writes to the Page Register
Six or more reset packets (Decoder Recovery Time from write to Page Register)	Six or more reset packets (Decoder Recovery Time from write to Page Register)
[Power-Off Followed by Power-On-Cycle (optional) 	[Power-Off Followed by Power-On-Cycle (optional)
[Three or more Reset Packets 	[Three or more Reset Packets
[Seven or more Verifies to a specific register] 	Or five or more Writes to a specific register
]] 	Six or more identical Write or Reset packets (Decoder Recovery Time from write to Data Register) ]]
Power Off, Optional 	Power Off, Optional
Physical Register Mode Packet	Physical Register Mode Packet	Physical Register Mode Packet	Physical Register Mode Packet	Physical Register Mode Packet	Physical Register Mode Packet	Physical Register Mode Packet	Physical Register Mode Packet
Long Preamble 	0 	0111CRRR 	0 	DDDDDDDD 	0 	EEEEEEEE 	1
Register	RRR Value	CVs, Accessory Decoder	CVs, Multifunction Decoder
1 	000 	Lower Address (CV413) 	Primary Address (CV1)
2 	001 	Undefined 	Start Voltage, CV2
3 	010 	Undefined 	Acceleration, CV3
4 	011 	Undefined 	Deceleration, CV4
5 	100 	Undefined 	Basic Configuration Register, CV29
6 	101 	Undefined 	Page Register, Reserved
7 	110 	Version Number CV7 	Version Number CV7
8 	111 	Manufacturer ID CV520 	Manufacturer ID CV8
=== Paged Mode ===
Packet Sequence for Paged Mode Addressing 	Packet Sequence for Paged Mode Addressing
Power On Cycle, if required (Optional) 	Power On Cycle, if required (Optional)
[Three or more Reset Packets 	[Three or more Reset Packets
Five or more writes to the Page Register 	Five or more writes to the Page Register
Six or more reset packets (Decoder Recovery Time from write to Page Register)	Six or more reset packets (Decoder Recovery Time from write to Page Register)
[Three or more Reset Packets 	[Three or more Reset Packets
[Five or more Verifies to a single Data Register 1 – 4 	Or five or more Writes to a single Data Register 1– 4
]] 	Six or more identical Write or Reset packets (Decoder Recovery Time from write to Data Register) ]]
Power Off, Optional 	Power Off, Optional
Physical Register Mode Packet	Physical Register Mode Packet	Physical Register Mode Packet	Physical Register Mode Packet	Physical Register Mode Packet	Physical Register Mode Packet	Physical Register Mode Packet	Physical Register Mode Packet
Long Preamble 	0 	0111CRRR 	0 	DDDDDDDD 	0 	EEEEEEEE 	1
Physical Registers for Use in Paged Mode CV Addressing	Physical Registers for Use in Paged Mode CV Addressing	Physical Registers for Use in Paged Mode CV Addressing
Register 	RRR Value 	
1 	000 	Data Register 0
2 	001 	Data Register 1
3 	010 	Data Register 2
4 	011 	Data Register 3
5 	100 	Basic Configuration Register Refer to S-9.2.3 regarding Physical Register addressing for other compatibility issues with the use of this register
6 	101 	Paging Register
* Registers 1 – 4 are Data Registers. They point to a set of four CVs, determined by the Paging Register. Register 0 points to the first CV in the set, Register 3 to the last CV.
* Register 5 is the Basic Configuration Register, which defines the basic configuration of the decoder. See RP-9.2.2 regarding CV29 (Multifunction Decoder) and RP-9.2.2 regarding CV541 on the content of this register in an Accessory Decoder 
* Register 6, the Paging Register. Used as an offset for the Data Registers, allowing access to the larger set of 1024 CVs available. Registers 5, 7 and 8 are not impacted by the content of the Page Register. See Service Mode Instruction Packets for Physical Register Addressing for more information 
In Paged CV Addressing Mode two Instruction Types (C) are defined.
Two Instruction types are defined:
* C=0, Verify register/CV contents
* C=1, Write register/CV contents
== Address Query ==
The Address Query is used by older decoders to verity a specific CV, which is the decoder address CV1 (Primary Address).
Address Query Packet	Address Query Packet	Address Query Packet	Address Query Packet	Address Query Packet	Address Query Packet	Address Query Packet	Address Query Packet
Long Preamble 	0 	AAAAAAAA 	0 	11111001 	0 	EEEEEEEE 	1
If the address contained in the packet matches that of the decoder, the decoder shall generate an acknowledgment. The Address Query can only be used with address 1 – 111 (binary). 
The Standard recommends this be used only after attempts to read CV1 using Direct or Paged modes have failed. After unsuccessful attempts at reading CV1, this method can be sued to verify CV1 matches the address of the decoder using this instruction.
== Service Mode Decoder Lock ==
This is an option. See TN-2-05 for details.
The Service Mode Decoder Lock instructions prevents service mode programming of some decoders, while allowing programming of other decoder on the same track. 
Decoder Lock Packet	Decoder Lock Packet	Decoder Lock Packet	Decoder Lock Packet	Decoder Lock Packet	Decoder Lock Packet	Decoder Lock Packet	Decoder Lock Packet	Decoder Lock Packet	Decoder Lock Packet
Long Preamble 	0 	00000000 	0 	11111001 	0 	0aaaaaaa 	0 	EEEEEEEE 	1
* aaaaaaa is the short (Primary) address of the decoder which will continue to accept programming instructions.
When a decoder receives this instruction, a decoder which includes this feature shall check its address against the address within the packet (aaaaaaa). If its address does not match, the decoder is considered locked and will ignore all following programming instructions.
== Decoder Factory Reset ==
Should it be necessary to reset a decoder to factory settings, the following command sequenceS-9.2.3: Several valid existing alternative means for achieving decoder factory reset are also in use. Manufacturers may continue to use these alternate means for performing a factory decoder reset but are required to also support the standard specified means in new designs for achieving this result. shall be used. The packet sequence for this command is identical to the packet sequence specified for Service Mode Instruction Packets for Physical Register Addressing. The Decoder Factory Reset packets are 3-byte packets of the format:
Decoder Factory Reset Packet	Decoder Factory Reset Packet	Decoder Factory Reset Packet	Decoder Factory Reset Packet	Decoder Factory Reset Packet	Decoder Factory Reset Packet	Decoder Factory Reset Packet	Decoder Factory Reset Packet
Long Preamble 	0 	01111111 	0 	00001000 	0 	01110111 	1
This instruction type initiates a write operation instructing the decoder to return to its factory default condition. As the packet sequence in service mode does not provide sufficient time for the process to be completed, the actual reset will occur during each subsequent power on cycle until such time the process has completed and all CVs returned to their factory default condition. During this interval a value of 255 shall be written to CV8, until such time that the decoder has successfully written all CVs to their factory defaults.
== References ==