Class CbusBootloaderPane
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,EventListener,Accessible,AbstractMRListener,CanListener,CanPanelInterface
Update March 2022 A new CBUS bootloader protocol supports two new features: - Reading back device ID - Reading back bootloader ID - Positive acknowledgement (or error) for write command - Possibility fro alternative checksum algorithms.
The module may buffer write commands in RAM, sending an immediate ACK and only writing when a FLASH page worth of data is received, which will result in a delayed ACK.
A new command, that will be ignored by the old bootloader, is used to request the bootloader ID. If no reply is received after a suitable timeout then the original protocol will be used. The old protocol is only supported for older PIC18 K8x devices. Modules based on any other devices are expected to support the new protocol.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enumBootloader checksum calculationprotected static enumBootloader protocolprotected static enumBootloader state machine statesprotected static enumBootloader status valuesstatic classNested class to create one of these using old-style defaults.Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected CbusBootloaderPane.BootChecksumprotected CbusBootloaderPane.BootProtocolprotected CbusBootloaderPane.BootState(package private) BusyDialogprotected intprotected JCheckBoxprotected HexRecordprotected intprotected intprotected JCheckBox(package private) CbusParameters(package private) CbusParameters(package private) HexFile(package private) final JFileChooser(package private) booleanprotected JCheckBox(package private) int(package private) intprotected JTextFieldprotected JButtonprotected JButtonprotected JButtonprotected booleanprotected intFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd to boot loader Logprotected booleandataIsFiltered(int address) Check if data is filtered (e.g., EEPROM selection unticked) Used only for AN247voiddispose()disconnect from the CBUSgetMenus()Creates a Menu List.getTitle()Provide a recommended title for an enclosing frame.(package private) intGet the delay to be inserted between bootloader data writes.protected booleanSee if any timers are running, ie waiting for a response from a physical Node.voidinit()Not sure this comment really applies here as init() does not use the tc Don't use initComponent() as memo doesn't yet exist when that gets called.void2nd stage of initialization, invoked after the Constructor is complete.(package private) booleanisProgrammingNeeded(byte[] d) Is Programming Needed Check if any data bytes actually need programmingprotected voidvoidProcess some outgoing CAN frames(package private) voidProtocol ErrorvoidProcesses incoming CAN repliesprotected voidprotected voidvoidrequestParam(int param) Request a single Parameter from a Physical Node(package private) voidSend the memory region write enable bit mask for CBUS bootloader protocolprotected voidsendData(int timeout) Send data to the hardware and keep a running checksumprotected voidSend bootloader reset frame to put the node back into operating mode.(package private) voidShow the bootloader ID Major/Minor version number, checksum algorithm error report capability(package private) voidShow the device ID Manufacturere and device from cbusdefs.h, device ID from the deviceprotected voidupdateChecksum(byte[] d) Add array of bytes to checksum(package private) voidWrite the next data frame for the bootloader(package private) voidWrite next data for AN247 protocol(package private) voidWrite next data for CBUS protocolMethods inherited from class jmri.jmrix.can.swing.CanPanel
getMemo, initContext, prependConnToStringMethods inherited from class jmri.util.swing.JmriPanel
getHelpTarget, getMinimumDimension, getWindowInterface, initComponents, isMultipleInstances, setWindowInterfaceMethods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface jmri.jmrix.can.CanListener
addTc, addTc, removeTc, removeTc
-
Field Details
-
nodeNumberField
-
configCheckBox
-
eepromCheckBox
-
moduleCheckBox
-
programButton
-
openFileChooserButton
-
readNodeParamsButton
-
hexFileChooser
-
hexFile
-
hardwareParams
-
fileParams
-
hexForBootloader
boolean hexForBootloader -
nodeNumber
int nodeNumber -
nextParam
int nextParam -
currentRecord
-
recordIndex
-
recordDone
-
busyDialog
-
bootProtocol
-
bootChecksum
-
bootState
-
bootAddress
-
checksum
-
dataFramesSent
-
dataTimeout
-
-
Constructor Details
-
CbusBootloaderPane
public CbusBootloaderPane()
-
-
Method Details
-
initComponents
2nd stage of initialization, invoked after the Constructor is complete.This needs to be connected to the initContext() method in implementing classes.
- Specified by:
initComponentsin interfaceCanPanelInterface- Overrides:
initComponentsin classCanPanel- Parameters:
memo- system connection.
-
init
Not sure this comment really applies here as init() does not use the tc Don't use initComponent() as memo doesn't yet exist when that gets called. Instead, call init() function from initComponents(memo) -
getTitle
Provide a recommended title for an enclosing frame. -
getMenus
Creates a Menu List. Provide menu items to add to a menu bar. -
getWriteDelay
int getWriteDelay()Get the delay to be inserted between bootloader data writes. For AN247, that has no handshaking can be slow or fast and then extended for slow writes to EEPROM and CONFIG. Only a single long timeout is used for CBUS protocol, which has full handshaking- Returns:
- Delay in ms
-
message
Process some outgoing CAN framesThe CBUS bootloader was originally "fire and forget", with no positive acknowledgement. We had to wait an indeterminate time and assume the write was successful.
A PIC based node will halt execution for some time ((10+ ms with newer Q series devices) whilst FLASH operations (erase and/or write) complete, during which time I/O will not be serviced. This is probably OK with CAN transport, assuming the ECAN continues to accept frames. With serial (UART) transport, as used by Pi-SPROG, the timing is much more critical as a single missed character will corrupt the node firmware.
Furthermore, on some platforms, e.g., Raspberry Pi, there can be considerable delays between the call to the traffic controller sendMessage() method and the message being sent by the transmit thread. This may be due to Flash file system operations and could be affected by the speed of the SD card. Once the message leaves the transmit thread, we are at the mercy of the underlying OS, where there can be further delays.
We could set an overlong timeout, but that would slow down the bootloading process in all cases.
To improve things somewhat we wait until the message has definitely reached the TC transmit thread, by looking for bootloader data write messages here. Testing indicates this is a marked improvement with no failures observed. This is unnecessary, and not used, for the new protocol which has a positive acknowledge mechanism.
- Specified by:
messagein interfaceCanListener- Parameters:
m- CanMessage
-
reply
Processes incoming CAN repliesThe bootloader is only interested in standard parameter responses and extended bootloader responses. Called when an incoming CanFrame is received from the CAN Network.
- Specified by:
replyin interfaceCanListener- Parameters:
r- the CanReply being received.
-
showDevId
Show the device ID Manufacturere and device from cbusdefs.h, device ID from the device- Parameters:
r- device ID reply
-
showBootId
Show the bootloader ID Major/Minor version number, checksum algorithm error report capability- Parameters:
r- Bootloader ID reply
-
sendBootEnables
void sendBootEnables()Send the memory region write enable bit mask for CBUS bootloader protocol -
protocolError
void protocolError()Protocol Error -
isProgrammingNeeded
Is Programming Needed Check if any data bytes actually need programming- Parameters:
d- data bytes to check- Returns:
- false if all bytes are 0xFF, else true
-
logFrame
-
dataIsFiltered
Check if data is filtered (e.g., EEPROM selection unticked) Used only for AN247- Parameters:
address- of data record- Returns:
- true if data is filtered and should not be written
-
sendData
Send data to the hardware and keep a running checksum- Parameters:
timeout- timeout for write operation
-
writeNextDataAn247
void writeNextDataAn247()Write next data for AN247 protocol -
writeNextDataCbus
void writeNextDataCbus()Write next data for CBUS protocol -
writeNextData
void writeNextData()Write the next data frame for the bootloader -
requestDevId
-
requestBootId
-
sendReset
Send bootloader reset frame to put the node back into operating mode. There will be no reply to this. -
updateChecksum
Add array of bytes to checksum- Parameters:
d- the array of bytes
-
requestParam
Request a single Parameter from a Physical NodeWill not send the request if there are existing active timers. Starts Parameter timeout
- Parameters:
param- Parameter Index Number, Index 0 is total parameters
-
hasActiveTimers
See if any timers are running, ie waiting for a response from a physical Node.- Returns:
- true if timers are running else false
-
addToLog
Add to boot loader Log- Parameters:
boottext- String console message
-
dispose
disconnect from the CBUS
-