001package jmri.jmrix.powerline.cp290; 002 003import jmri.jmrix.powerline.SerialReply; 004import jmri.jmrix.powerline.SerialTrafficController; 005 006/** 007 * Contains the data payload of a serial reply packet. Note that it's _only_ the 008 * payload. 009 * 010 * @author Bob Jacobsen Copyright (C) 2002, 2006, 2007, 2008 Converted to 011 * multiple connection 012 * @author kcameron Copyright (C) 2011 013 */ 014public class SpecificReply extends jmri.jmrix.powerline.SerialReply { 015 016 // create a new one 017 public SpecificReply(SerialTrafficController tc) { 018 super(tc); 019 setBinary(true); 020 } 021 022 public SpecificReply(SerialTrafficController tc, String s) { 023 super(tc, s); 024 setBinary(true); 025 } 026 027 public SpecificReply(SerialTrafficController tc, SerialReply l) { 028 super(tc, l); 029 setBinary(true); 030 } 031 032 /** 033 * Find 1st byte that's not 0xFF, or -1 if none 034 * @return -1 or index to first valid byte 035 */ 036 int startIndex() { 037 int len = getNumDataElements(); 038 for (int i = 0; i < len; i++) { 039 if ((getElement(i) & 0xFF) != 0xFF) { 040 return i; 041 } 042 } 043 return -1; 044 } 045 046 /** 047 * Translate packet to text 048 */ 049 @Override 050 public String toMonitorString() { 051 String test = Constants.toMonitorString(this); 052 return "Recv[" + getNumDataElements() + "]: " + test + "\n"; 053 } 054 055} 056 057