Package org.km3net.clb.remote
Class CmdSystem
- java.lang.Object
-
- org.km3net.clb.remote.Control.CommandGroup
-
- org.km3net.clb.remote.CmdSystem
-
public class CmdSystem extends Control.CommandGroup
Implements system commands.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CmdSystem.DateRev
Class enclosing date and revision.static class
CmdSystem.LogData
static class
CmdSystem.PersistentLogLines
Helper class to get the last log lies.static class
CmdSystem.RtConfig
-
Field Summary
-
Fields inherited from class org.km3net.clb.remote.Control.CommandGroup
ctl, msg
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Response<java.lang.Void>
boot(int imgNo)
Attempts to boot the provided image number.Response<java.lang.Void>
consoleTunnelDeinit()
Deinitializes the console tunnel.Response<java.lang.Void>
consoleTunnelInit(java.net.InetSocketAddress addr)
Initializes a consolse tunnel to the specified Socket address.Response<java.lang.Void>
consoleTunnelSend(java.lang.String ptp, java.lang.String secLm)
Sends character data to the PTP and 2nd LM32.void
consoleTunnelSetRecvHandler(MessageEventHandler<java.lang.String[]> handler)
Sets the console tunnel receive handler.Response<java.lang.Void>
coreDumpClear()
Send a ping command.Response<CmdSystem.DateRev>
dateRev()
This command returns the date and revision information of the system, both the hardware and software version.static ImageInfo
decodeImageInfo(short pos, MessageReader mr)
void
emitUpdate(int chunkNo, byte[] chunk)
Emits a single chunk of the update (suitable for multicast).Response<java.lang.Void>
endUpdate()
Stops an update.Response<java.lang.Void>
eventTarget()
Configures this controller as the target for events.Response<ImageInfo[]>
getImageInfo()
Returns a list of images on the flash.Response<CmdSystem.RtConfig>
getRtConfig()
Gets the runtime configuration.Response<CmdSystem.LogData>
logGet(long lastId)
Returns a number of log-lines from the connected CLB.void
logPersistentGet(int noOfLines, CmdSystem.PersistentLogLines callback)
Gets a number of persistet log-lines.Response<java.lang.Void>
ping()
Send a ping command.Response<java.lang.Void>
sendUpdate(int chunkNo, byte[] chunk)
Send a single chunk of the update (suitable for unicast).Response<java.lang.Void>
setEventTarget(java.net.InetSocketAddress sAddr)
Sets or clears an event target with the specified socket address.Response<CmdSystem.RtConfig>
setRtConfig(CmdSystem.RtConfig rtConfig)
Sets the runtime configuration.Response<java.lang.Void>
startUpdate(int imgIdx, int chunkCnt)
Initiates an update.Response<java.lang.Void>
stopGolden()
Prevents the golden image from booting the runtime image.Response<java.lang.Void>
unlockGolden()
Unlocks the golden image for writing.Response<java.lang.Boolean>
verify(int imgNo, int chunkNo, byte[] chunk)
Verifies a part of the image.Response<java.lang.Boolean>
verify(int imgNo, int chunkNo, long crc)
-
-
-
Method Detail
-
ping
public Response<java.lang.Void> ping()
Send a ping command. Note that it will actually not be executed unless you attempt to get the response.
-
dateRev
public Response<CmdSystem.DateRev> dateRev()
This command returns the date and revision information of the system, both the hardware and software version. The values are both 'hex' encoded, but human readable. The highest 6 bytes are the date, with the year in the upper two bytes, the month in the next two bytes and the day in the last two bytes. The lower two bytes are that days revision. E.g. 0x13090802 (0xYYMMDDRR) is the third revision (02, its zero based), on the 8th of September 2013. Its been encoded like this to be easy to display using printf-like functions:System.out.printf("Date & Revision: " + "Hardware: %08x, Software: %08x\n", dr.hwDateRev, dr.swDateRev);
- Returns:
- A response containing a date and revision object.
-
eventTarget
public Response<java.lang.Void> eventTarget()
Configures this controller as the target for events.- See Also:
setEventTarget(InetSocketAddress)
-
setEventTarget
public Response<java.lang.Void> setEventTarget(java.net.InetSocketAddress sAddr)
Sets or clears an event target with the specified socket address.- Parameters:
sAddr
- The socket address, or null to clear. Note: When closing a connection its proper to clear the event target.
-
startUpdate
public Response<java.lang.Void> startUpdate(int imgIdx, int chunkCnt)
Initiates an update.- Parameters:
imgIdx
- Image indexchunkCnt
- Chunk count- Returns:
- Response object.
-
sendUpdate
public Response<java.lang.Void> sendUpdate(int chunkNo, byte[] chunk)
Send a single chunk of the update (suitable for unicast).- Parameters:
chunkNo
- The chunk indexchunk
- The chunk data (512 bytes).- Returns:
- Response object of type Void.
-
emitUpdate
public void emitUpdate(int chunkNo, byte[] chunk)
Emits a single chunk of the update (suitable for multicast).- Parameters:
chunkNo
- The chunk indexchunk
- The chunk data (512 bytes).
-
endUpdate
public Response<java.lang.Void> endUpdate()
Stops an update.- Returns:
- Response object of type Void.
-
unlockGolden
public Response<java.lang.Void> unlockGolden()
Unlocks the golden image for writing.
-
stopGolden
public Response<java.lang.Void> stopGolden()
Prevents the golden image from booting the runtime image. Must be done before the actual runtime image is booted, of course.
-
boot
public Response<java.lang.Void> boot(int imgNo)
Attempts to boot the provided image number.- Parameters:
imgNo
- Number to boot.
-
verify
public Response<java.lang.Boolean> verify(int imgNo, int chunkNo, byte[] chunk)
Verifies a part of the image.- Parameters:
imgNo
- Image numberchunkNo
- Chunk numberchunk
- Data to compare- Returns:
- True - They equal, false - they do not equal
-
verify
public Response<java.lang.Boolean> verify(int imgNo, int chunkNo, long crc)
-
logGet
public Response<CmdSystem.LogData> logGet(long lastId)
Returns a number of log-lines from the connected CLB. Each log line is identified by an incremental number. This number is used as an offset to load logging lines. Note: Requesting logging is purely done on the basis of polling. Example code of an application showing the logging of a CLB:Control ctrl = new Control("192.168.1.10"); long lastId = 0; while (true) { LogData ld = ctrl.sys.logGet(lastId).get(); for (String line : ld.lastLines) { System.out.println(line); } lastId = ld.lastId; if (ld.lastLines.length == 0) { // apparently there was nothing, so we wait for 1 second. Thread.sleep(1000); } }
- Parameters:
lastId
- The last log-line ID received, or else 0.- Returns:
- A log data object.
-
logPersistentGet
public void logPersistentGet(int noOfLines, CmdSystem.PersistentLogLines callback)
Gets a number of persistet log-lines. Since this can be quite a lot, a callback is used to provide the lines as they come in.- Parameters:
noOfLines
- the number of lines to return (max).callback
- The callback which handles the lines as they come in.
-
consoleTunnelInit
public Response<java.lang.Void> consoleTunnelInit(java.net.InetSocketAddress addr)
Initializes a consolse tunnel to the specified Socket address.- Parameters:
addr
- The socket address. Provide null to use this control instance.- Returns:
- The response object.
-
consoleTunnelDeinit
public Response<java.lang.Void> consoleTunnelDeinit()
Deinitializes the console tunnel. Also prevents unnecessary usage of resources.- Returns:
- The response object.
-
consoleTunnelSend
public Response<java.lang.Void> consoleTunnelSend(java.lang.String ptp, java.lang.String secLm)
Sends character data to the PTP and 2nd LM32.- Parameters:
ptp
- The PTP core character data to send. May be empty or null.secLm
- The 2nd LM32 character data to send. May be empty or null.- Returns:
- The response object.
-
consoleTunnelSetRecvHandler
public void consoleTunnelSetRecvHandler(MessageEventHandler<java.lang.String[]> handler)
Sets the console tunnel receive handler. Only supports one handler! The handler (should) always receive two strings, the first is data from the PTP core the second from the 2nd LM32. Strings may be empty is no new data is available.- Parameters:
handler
- The handler, or null to remove the handler.
-
decodeImageInfo
public static ImageInfo decodeImageInfo(short pos, MessageReader mr)
-
getImageInfo
public Response<ImageInfo[]> getImageInfo()
Returns a list of images on the flash.- Returns:
- An array of image information objects.
-
setRtConfig
public Response<CmdSystem.RtConfig> setRtConfig(CmdSystem.RtConfig rtConfig)
Sets the runtime configuration.- Parameters:
rtConfig
- The runtime configuration to apply- Returns:
- The applied runtime configuration (should be the same)
-
getRtConfig
public Response<CmdSystem.RtConfig> getRtConfig()
Gets the runtime configuration.- Returns:
- The current runtime configuration.
-
coreDumpClear
public Response<java.lang.Void> coreDumpClear()
Send a ping command. Note that it will actually not be executed unless you attempt to get the response.
-
-