public LightTemperatureIntro() { try { RS232 rs232 = new RS232(); rs232.println("Welcome!"); rs232.println("Please connect one or both of the"); rs232.println("sensors that came with your evaluation kit"); rs232.println("to the evaluation board's I2C connectors"); TMP75 tmp = null; TSL2561 tsl = null; intro: for (; ; ) { if (tmp == null) { tmp = new TMP75(0x9e); } if (tmp != null) { try { tmp.getTemp(); } catch (IOException e1) { tmp = null; } } if (tsl == null) { try { tsl = new TSL2561(0x72); } catch (IOException e2) { } } if (tsl != null) { try { tsl.getChannel0(); } catch (IOException e) { tsl = null; } } if (tmp != null || tsl != null) { break intro; } try { ThreadExt.sleep(1); } catch (InterruptedException e) { } } if (tmp != null) { rs232.println("TMP75 detected."); } if (tsl != null) { rs232.println("TSL2651 detected."); } } catch (IOException e) { } }
/** * Display the error message. * * @param code the error code. * @param message the error message (textual error description). * @param jpc points to the last bytecode to be executed when the error occured. * @param npc points to the machine instruction that was producing the error. * @param jpcext set if jpc points to external memory (e.g. flash). * @see onError(int code, int jpc, int npc, boolean jpcext). */ public static void onError(int code, String message, int jpc, int npc, boolean jpcext) { // set current flash bank where error occured String jpcbank; if (jpcext) { jpcbank = Management.getProperty("system.userbank"); if (jpcbank == null) jpcbank = "0"; } else { // when jpcext is set, error was caused by ROM code jpcbank = "f"; } // Print the error message to the RS232 port, using standard // communication parameters. // When the RS232-Terminal of the JControl/IDE is opened, this message // is used to // back-trace the error automatically. try { RS232 rs232 = new RS232(); String errorString = "\nJControl/ErrorHandler: Code=" .concat(String.valueOf(code)) .concat(" NPC=0xf") .concat(Integer.toHexString(npc)) .concat(" JPC=0x") .concat(jpcbank) .concat(Integer.toHexString(jpc)) .concat("\n"); rs232.write(errorString.getBytes(), 0, errorString.length()); rs232.close(); } catch (IOException e) { } // create keyboard instance m_keyboard = new Keyboard(); // start timing thread to control buzzer signals and reboot Thread t = new Thread(new ErrorHandler()); t.setDaemon(true); t.start(); // generate error message string when not passed by caller if (message == null) { if ((code < 0) || (code >= ERROR_MESSAGES.length)) { message = "ErrorCode 0x".concat(Integer.toHexString(code)); } else { message = ERROR_MESSAGES[code]; } } // Print the error message to the RS232 port, using standard // communication parameters. // When the RS232-Terminal of the JControl/IDE is opened, this message // is used to // back-trace the error automatically. try { RS232 rs232 = new RS232(); String errorString = "\nJControl/ErrorHandler: Code=" .concat(String.valueOf(code)) .concat(" NPC=0xf") .concat(Integer.toHexString(npc)) .concat(" JPC=0x") .concat(jpcbank) .concat(Integer.toHexString(jpc)) .concat("\n"); rs232.write(errorString.getBytes(), 0, errorString.length()); rs232.close(); } catch (IOException e) { } // wait for keypress m_keyboard.read(); }