You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(21) |
Nov
(12) |
Dec
(41) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(25) |
Feb
(54) |
Mar
(63) |
Apr
(52) |
May
(17) |
Jun
(3) |
Jul
(3) |
Aug
(5) |
Sep
(49) |
Oct
(50) |
Nov
(34) |
Dec
(14) |
2009 |
Jan
(9) |
Feb
(15) |
Mar
(38) |
Apr
(12) |
May
(35) |
Jun
(20) |
Jul
(2) |
Aug
(7) |
Sep
(36) |
Oct
(24) |
Nov
(2) |
Dec
(2) |
2010 |
Jan
(14) |
Feb
(1) |
Mar
(36) |
Apr
(2) |
May
(4) |
Jun
(6) |
Jul
(35) |
Aug
(11) |
Sep
(8) |
Oct
(3) |
Nov
|
Dec
(1) |
2011 |
Jan
(11) |
Feb
(12) |
Mar
(3) |
Apr
(7) |
May
(12) |
Jun
(8) |
Jul
|
Aug
(3) |
Sep
(4) |
Oct
|
Nov
(2) |
Dec
(4) |
2012 |
Jan
(2) |
Feb
(1) |
Mar
(14) |
Apr
(5) |
May
(28) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(21) |
Nov
(4) |
Dec
(1) |
2013 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <jo...@us...> - 2008-10-29 12:07:31
|
Revision: 388 http://mspsim.svn.sourceforge.net/mspsim/?rev=388&view=rev Author: joxe Date: 2008-10-29 12:07:24 +0000 (Wed, 29 Oct 2008) Log Message: ----------- fixed bug that made VREG_OFF go to SFD_SEARCH due to flush Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java mspsim/se/sics/mspsim/cli/DebugCommands.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-29 11:34:26 UTC (rev 387) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-29 12:07:24 UTC (rev 388) @@ -357,7 +357,7 @@ } private boolean setState(RadioState state) { - //if(DEBUG) log("State Transition from " + stateMachine + " to " + state); + if(DEBUG) log("State transition from " + stateMachine + " to " + state); stateMachine = state; switch(stateMachine) { @@ -424,9 +424,7 @@ updateCCA(); break; } - return true; - } /* Receive a byte from the radio medium @@ -443,7 +441,8 @@ // if (stateMachine == RX_WAIT) { // setState(RX_SFD_SEARCH); // } - log("RF Byte received: " + Utils.hex8(data) + " state: " + stateMachine + " noZeroes: " + zeroSymbols); + log("RF Byte received: " + Utils.hex8(data) + " state: " + stateMachine + " noZeroes: " + zeroSymbols + + ((stateMachine == RadioState.RX_SFD_SEARCH || stateMachine == RadioState.RX_FRAME) ? "" : " *** Ignored")); if(stateMachine == RadioState.RX_SFD_SEARCH) { @@ -499,8 +498,6 @@ setState(RadioState.RX_WAIT); } } - } else if (DEBUG) { - log("*** Ignoring byte from air state: " + stateMachine); } } @@ -821,7 +818,13 @@ setFIFO(false); overflow = false; /* goto RX Calibrate */ - setState(RadioState.RX_SFD_SEARCH); + if( (stateMachine == RadioState.RX_CALIBRATE) || + (stateMachine == RadioState.RX_SFD_SEARCH) || + (stateMachine == RadioState.RX_FRAME) || + (stateMachine == RadioState.RX_OVERFLOW) || + (stateMachine == RadioState.RX_WAIT)) { + setState(RadioState.RX_SFD_SEARCH); + } } // TODO: update any pins here? @@ -960,19 +963,18 @@ listener = rf; } - public void setVRegOn(boolean on) { - if(this.on == on) return; + public void setVRegOn(boolean newOn) { + if(on == newOn) return; - if(on) { + if(newOn) { // 0.6ms maximum vreg startup from datasheet pg 13 cpu.scheduleTimeEventMillis(vregEvent, 0.1); if (DEBUG) log(getName() + ": Scheduling vregEvent at: cyc = " + cpu.cycles + " target: " + vregEvent.getTime() + " current: " + cpu.getTime()); } else { - this.on = on; + on = false; setState(RadioState.VREG_OFF); } - //this.on = on; } public void setChipSelect(boolean select) { Modified: mspsim/se/sics/mspsim/cli/DebugCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-10-29 11:34:26 UTC (rev 387) +++ mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-10-29 12:07:24 UTC (rev 388) @@ -196,8 +196,10 @@ MapEntry[] entries = context.getMapTable().getEntries(regExp); for (int i = 0; i < entries.length; i++) { MapEntry mapEntry = entries[i]; + int address = mapEntry.getAddress(); context.out.println(" " + mapEntry.getName() + " at $" + - Utils.hex16(mapEntry.getAddress())); + Utils.hex16(address) + " (" + Utils.hex8(cpu.memory[address]) + + " " + Utils.hex8(cpu.memory[address + 1]) + ")"); } return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-10-28 22:30:52
|
Revision: 386 http://mspsim.svn.sourceforge.net/mspsim/?rev=386&view=rev Author: joxe Date: 2008-10-28 22:30:44 +0000 (Tue, 28 Oct 2008) Log Message: ----------- Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-28 16:11:39 UTC (rev 385) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-28 22:30:44 UTC (rev 386) @@ -339,7 +339,7 @@ } }; private boolean currentSFD; - private boolean currentFifo; + private boolean currentFIFO; private boolean overflow = false; // TODO: super(cpu) and chip autoregister chips into the CPU. @@ -488,9 +488,9 @@ // In RX mode, FIFOP goes high, if threshold is higher than frame length.... // Should take a RSSI value as input or use a set-RSSI value... - memory[RAM_RXFIFO + ((rxfifoWritePos + 128 -2) & 127)] = (registers[REG_RSSI]) & 0xff; + memory[RAM_RXFIFO + ((rxfifoWritePos + 128 - 2) & 127)] = (registers[REG_RSSI]) & 0xff; // Set CRC ok and add a correlation - memory[RAM_RXFIFO + ((rxfifoWritePos + 128 -1) & 127)] = 37 | 0x80; + memory[RAM_RXFIFO + ((rxfifoWritePos + 128 - 1) & 127)] = 37 | 0x80; setFIFOP(true); setSFD(false); lastPacketStart = (rxfifoWritePos + 128 - rxlen) & 127; @@ -594,8 +594,11 @@ return; //break; case READ_RXFIFO: - if(rxfifoLen == 0) - break; + if(rxfifoLen == 0) { + /* nothing to read, just return a zero */ + source.byteReceived(0); + return; + } if(DEBUG) log("RXFIFO READ " + rxfifoReadPos + " => " + (memory[RAM_RXFIFO + rxfifoReadPos] & 0xFF) + " size: " + rxfifoLen); source.byteReceived( (memory[RAM_RXFIFO + rxfifoReadPos] & 0xFF) ); @@ -611,12 +614,11 @@ if (rxfifoReadPos >= 128) { rxfifoReadPos = 0; } - // When is this set to "false" - when is interrupt de-triggered? // TODO: // -MT FIFOP is lowered when there are less than IOCFG0:FIFOP_THR bytes in the RXFIFO // If FIFO_THR is greater than the frame length, FIFOP goes low when the first byte is read out. // As long as we are in "OVERFLOW" the fifoP is not cleared. - if (fifoP && !overflow) { + if (fifoP) { if (DEBUG) log("*** FIFOP cleared at: " + rxfifoReadPos + " lastPacketStartPos: " + lastPacketStart); setFIFOP(false); @@ -656,7 +658,6 @@ } break; } - source.byteReceived(oldStatus); } } @@ -878,8 +879,8 @@ } private void setFIFO(boolean fifo) { - currentFifo = fifo; if (DEBUG) log(getName() + " setting FIFO to " + fifo); + currentFIFO = fifo; fifoPort.setPinState(fifoPin, fifo ? 1 : 0); } @@ -1050,7 +1051,7 @@ "\n OSC_Stable: " + ((status & STATUS_XOSC16M_STABLE) > 0) + "\n RSSI_Valid: " + ((status & STATUS_RSSI_VALID) > 0) + " CCA: " + cca + "\n FIFOP Polarity: " + ((registers[REG_IOCFG0] & FIFOP_POLARITY) == FIFOP_POLARITY) + - " FIFOP: " + fifoP + " FIFO: " + currentFifo + " SFD: " + currentSFD + + " FIFOP: " + fifoP + " FIFO: " + currentFIFO + " SFD: " + currentSFD + "\n Radio State: " + stateMachine + " rxFifoLen: " + rxfifoLen + " rxFifoWritePos: " + rxfifoWritePos + " rxFifoReadPos: " + rxfifoReadPos + "\n SPI State: " + state + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-10-28 16:11:40
|
Revision: 385 http://mspsim.svn.sourceforge.net/mspsim/?rev=385&view=rev Author: joxe Date: 2008-10-28 16:11:39 +0000 (Tue, 28 Oct 2008) Log Message: ----------- added overflow state Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-28 13:39:31 UTC (rev 384) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-28 16:11:39 UTC (rev 385) @@ -340,6 +340,7 @@ }; private boolean currentSFD; private boolean currentFifo; + private boolean overflow = false; // TODO: super(cpu) and chip autoregister chips into the CPU. public CC2420(MSP430Core cpu) { @@ -351,7 +352,7 @@ fifoP = false; rxfifoReadPos = 0; rxfifoWritePos = 0; - + overflow = false; cpu.addChip(this); } @@ -487,9 +488,9 @@ // In RX mode, FIFOP goes high, if threshold is higher than frame length.... // Should take a RSSI value as input or use a set-RSSI value... - memory[RAM_RXFIFO + (rxfifoWritePos - 2)] = (registers[REG_RSSI]) & 0xff; + memory[RAM_RXFIFO + ((rxfifoWritePos + 128 -2) & 127)] = (registers[REG_RSSI]) & 0xff; // Set CRC ok and add a correlation - memory[RAM_RXFIFO + (rxfifoWritePos -1 )] = 37 | 0x80; + memory[RAM_RXFIFO + ((rxfifoWritePos + 128 -1) & 127)] = 37 | 0x80; setFIFOP(true); setSFD(false); lastPacketStart = (rxfifoWritePos + 128 - rxlen) & 127; @@ -596,7 +597,7 @@ if(rxfifoLen == 0) break; if(DEBUG) log("RXFIFO READ " + rxfifoReadPos + " => " + - (memory[RAM_RXFIFO + rxfifoReadPos] & 0xFF) ); + (memory[RAM_RXFIFO + rxfifoReadPos] & 0xFF) + " size: " + rxfifoLen); source.byteReceived( (memory[RAM_RXFIFO + rxfifoReadPos] & 0xFF) ); rxfifoReadPos++; @@ -615,7 +616,7 @@ // -MT FIFOP is lowered when there are less than IOCFG0:FIFOP_THR bytes in the RXFIFO // If FIFO_THR is greater than the frame length, FIFOP goes low when the first byte is read out. // As long as we are in "OVERFLOW" the fifoP is not cleared. - if (fifoP && stateMachine != RadioState.RX_OVERFLOW) { + if (fifoP && !overflow) { if (DEBUG) log("*** FIFOP cleared at: " + rxfifoReadPos + " lastPacketStartPos: " + lastPacketStart); setFIFOP(false); @@ -778,7 +779,12 @@ if (DEBUG) log("Completed Transmission."); status &= ~STATUS_TX_ACTIVE; setSFD(false); - setState(RadioState.RX_CALIBRATE); + if (overflow) { + /* TODO: is it going back to overflow here ?=? */ + setState(RadioState.RX_OVERFLOW); + } else { + setState(RadioState.RX_CALIBRATE); + } txfifoFlush = true; } } @@ -812,6 +818,9 @@ setSFD(false); setFIFOP(false); setFIFO(false); + overflow = false; + /* goto RX Calibrate */ + setState(RadioState.RX_SFD_SEARCH); } // TODO: update any pins here? @@ -879,6 +888,7 @@ if (DEBUG) log("RXFIFO Overflow! Read Pos: " + rxfifoReadPos + " Write Pos: " + rxfifoWritePos); setFIFOP(true); setFIFO(false); + overflow = true; setState(RadioState.RX_OVERFLOW); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-10-28 13:39:39
|
Revision: 384 http://mspsim.svn.sourceforge.net/mspsim/?rev=384&view=rev Author: joxe Date: 2008-10-28 13:39:31 +0000 (Tue, 28 Oct 2008) Log Message: ----------- autoflush all when VREG_OFF Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-28 12:02:13 UTC (rev 383) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-28 13:39:31 UTC (rev 384) @@ -338,6 +338,8 @@ } } }; + private boolean currentSFD; + private boolean currentFifo; // TODO: super(cpu) and chip autoregister chips into the CPU. public CC2420(MSP430Core cpu) { @@ -361,6 +363,8 @@ case VREG_OFF: if (DEBUG) log("VREG Off."); + flushRX(); + flushTX(); status &= ~(STATUS_RSSI_VALID | STATUS_XOSC16M_STABLE); setMode(MODE_POWER_OFF); updateCCA(); @@ -463,7 +467,7 @@ } else if(stateMachine == RadioState.RX_FRAME) { if(rxfifoLen == 128) { setRxOverflow(); - }else{ + } else { memory[RAM_RXFIFO + rxfifoWritePos++] = data & 0xFF; rxfifoLen++; @@ -473,7 +477,7 @@ } if(rxread == 0) { - rxlen = (int)data; + rxlen = data & 0xff; if (DEBUG) log("RX: Start frame length " + rxlen); // FIFO pin goes high after length byte is written to RXFIFO setFIFO(true); @@ -610,7 +614,8 @@ // TODO: // -MT FIFOP is lowered when there are less than IOCFG0:FIFOP_THR bytes in the RXFIFO // If FIFO_THR is greater than the frame length, FIFOP goes low when the first byte is read out. - if (fifoP) { + // As long as we are in "OVERFLOW" the fifoP is not cleared. + if (fifoP && stateMachine != RadioState.RX_OVERFLOW) { if (DEBUG) log("*** FIFOP cleared at: " + rxfifoReadPos + " lastPacketStartPos: " + lastPacketStart); setFIFOP(false); @@ -806,6 +811,7 @@ rxfifoLen = 0; setSFD(false); setFIFOP(false); + setFIFO(false); } // TODO: update any pins here? @@ -840,7 +846,7 @@ sfdPort.setPinState(sfdPin, sfd ? 0 : 1); else sfdPort.setPinState(sfdPin, sfd ? 1 : 0); - + currentSFD = sfd; if (DEBUG) log("SFD: " + sfd + " " + cpu.cycles); } @@ -862,16 +868,20 @@ } } + private void setFIFO(boolean fifo) { + currentFifo = fifo; + if (DEBUG) log(getName() + " setting FIFO to " + fifo); + fifoPort.setPinState(fifoPin, fifo ? 1 : 0); + } + + private void setRxOverflow() { if (DEBUG) log("RXFIFO Overflow! Read Pos: " + rxfifoReadPos + " Write Pos: " + rxfifoWritePos); setFIFOP(true); setFIFO(false); + setState(RadioState.RX_OVERFLOW); } - private void setFIFO(boolean fifo) { - if (DEBUG) log(getName() + " setting FIFO to " + fifo); - fifoPort.setPinState(fifoPin, fifo ? 1 : 0); - } /***************************************************************************** * External APIs for simulators simulating Radio medium, etc. @@ -1028,10 +1038,11 @@ public String chipinfo() { return " VREG_ON: " + on + "\n OSC_Stable: " + ((status & STATUS_XOSC16M_STABLE) > 0) + - "\n RSSI_Valid: " + ((status & STATUS_RSSI_VALID) > 0) + - "\n CCA: " + cca + + "\n RSSI_Valid: " + ((status & STATUS_RSSI_VALID) > 0) + " CCA: " + cca + "\n FIFOP Polarity: " + ((registers[REG_IOCFG0] & FIFOP_POLARITY) == FIFOP_POLARITY) + - "\n Radio State: " + stateMachine + + " FIFOP: " + fifoP + " FIFO: " + currentFifo + " SFD: " + currentSFD + + "\n Radio State: " + stateMachine + " rxFifoLen: " + rxfifoLen + " rxFifoWritePos: " + + rxfifoWritePos + " rxFifoReadPos: " + rxfifoReadPos + "\n SPI State: " + state + "\n"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-10-28 12:02:26
|
Revision: 383 http://mspsim.svn.sourceforge.net/mspsim/?rev=383&view=rev Author: joxe Date: 2008-10-28 12:02:13 +0000 (Tue, 28 Oct 2008) Log Message: ----------- fixed CCA and RSSI Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-28 09:33:52 UTC (rev 382) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-28 12:02:13 UTC (rev 383) @@ -240,7 +240,7 @@ private int rxlen; private int rxread; private int lastPacketStart; - private int zero_symbols; + private int zeroSymbols; private boolean ramRead = false; /* RSSI is an externally set value of the RSSI for this CC2420 */ @@ -380,7 +380,7 @@ break; case RX_SFD_SEARCH: - zero_symbols = 0; + zeroSymbols = 0; // RSSI valid here? status |= STATUS_RSSI_VALID; updateCCA(); @@ -438,27 +438,27 @@ // if (stateMachine == RX_WAIT) { // setState(RX_SFD_SEARCH); // } + log("RF Byte received: " + Utils.hex8(data) + " state: " + stateMachine + " noZeroes: " + zeroSymbols); + if(stateMachine == RadioState.RX_SFD_SEARCH) { // Look for the preamble (4 zero bytes) followed by the SFD byte 0x7A if(data == 0) { // Count zero bytes - zero_symbols++; + if (zeroSymbols < 4) zeroSymbols++; return; + } else if(zeroSymbols == 4 && data == 0x7A) { + // If the received byte is !zero, we have counted 4 zero bytes prior to this one, + // and the current received byte == 0x7A (SFD), we're in sync. + // In RX mode, SFD goes high when the SFD is received + setSFD(true); + if (DEBUG) log("RX: Preamble/SFD Synchronized."); + rxread = 0; + setState(RadioState.RX_FRAME); + } else { + /* if not four zeros and 0x7A then no zeroes... */ + zeroSymbols = 0; } - // If the received byte is !zero, we have counted 4 zero bytes prior to this one, - // and the current received byte == 0x7A (SFD), we're in sync. - if(zero_symbols == 4) { - if(data == 0x7A) { - // In RX mode, SFD goes high when the SFD is received - setSFD(true); - if (DEBUG) log("RX: Preamble/SFD Synchronized."); - rxread = 0; - setState(RadioState.RX_FRAME); - } else { - zero_symbols = 0; - } - } } else if(stateMachine == RadioState.RX_FRAME) { if(rxfifoLen == 128) { @@ -744,6 +744,139 @@ } } + private void shrNext() { + if(shrPos == 5) { + // Set SFD high + setSFD(true); + setState(RadioState.TX_FRAME); + } else { + if (listener != null) { + if (DEBUG) log("transmitting byte: " + Utils.hex8(SHR[shrPos])); + listener.receivedByte(SHR[shrPos]); + } + shrPos++; + cpu.scheduleTimeEventMillis(shrEvent, SYMBOL_PERIOD * 2); + } + } + + private void txNext() { + if(txfifoPos <= memory[RAM_TXFIFO]) { + if (listener != null) { + if (DEBUG) log("transmitting byte: " + Utils.hex8(memory[RAM_TXFIFO + txfifoPos] & 0xFF)); + listener.receivedByte((byte)(memory[RAM_TXFIFO + txfifoPos] & 0xFF)); + } + txfifoPos++; + // Two symbol periods to send a byte... + long time = cpu.scheduleTimeEventMillis(sendEvent, SYMBOL_PERIOD * 2); +// log("Scheduling 2 SYMB at: " + time + " getTime(now): " + cpu.getTime()); + } else { + if (DEBUG) log("Completed Transmission."); + status &= ~STATUS_TX_ACTIVE; + setSFD(false); + setState(RadioState.RX_CALIBRATE); + txfifoFlush = true; + } + } + + private void setSymbolEvent(int symbols) { + double period = SYMBOL_PERIOD * symbols; + cpu.scheduleTimeEventMillis(symbolEvent, period); + //log("Set Symbol event: " + period); + } + + private void startOscillator() { + // 1ms crystal startup from datasheet pg12 + cpu.scheduleTimeEventMillis(oscillatorEvent, 1); + } + + private void stopOscillator() { + status &= ~STATUS_XOSC16M_STABLE; + setState(RadioState.POWER_DOWN); + if (DEBUG) log("Oscillator Off."); + // Reset state + setFIFOP(false); + } + + private void flushRX() { + if (DEBUG) { + log("Flushing RX len = " + rxfifoLen); + } + rxfifoReadPos = 0; + rxfifoWritePos = 0; + rxfifoLen = 0; + setSFD(false); + setFIFOP(false); + } + + // TODO: update any pins here? + private void flushTX() { + txCursor = 0; + } + + private void updateCCA() { + boolean oldCCA = cca; + int ccaMux = (registers[REG_IOCFG1] & CCAMUX); + + if (ccaMux == CCAMUX_CCA) { + /* If RSSI is less than -95 then we have CCA / clear channel! */ + cca = (status & STATUS_RSSI_VALID) > 0 && rssi < -95; + } else if (ccaMux == CCAMUX_XOSC16M_STABLE) { + cca = (status & STATUS_XOSC16M_STABLE) > 0; + } + + if (cca != oldCCA) { + setInternalCCA(cca); + } + } + + private void setInternalCCA(boolean clear) { + setCCAPin(clear); + if (DEBUG) log("Internal CCA: " + clear); + } + + + private void setSFD(boolean sfd) { + if( (registers[REG_IOCFG0] & SFD_POLARITY) == SFD_POLARITY) + sfdPort.setPinState(sfdPin, sfd ? 0 : 1); + else + sfdPort.setPinState(sfdPin, sfd ? 1 : 0); + + if (DEBUG) log("SFD: " + sfd + " " + cpu.cycles); + } + + private void setCCAPin(boolean cca) { + if (DEBUG) log("Setting CCA to: " + cca); + if( (registers[REG_IOCFG0] & CCA_POLARITY) == CCA_POLARITY) + ccaPort.setPinState(ccaPin, cca ? 0 : 1); + else + ccaPort.setPinState(ccaPin, cca ? 1 : 0); + } + + private void setFIFOP(boolean fifop) { + fifoP = fifop; + if (DEBUG) log(getName() + " setting FIFOP to " + fifop); + if( (registers[REG_IOCFG0] & FIFOP_POLARITY) == FIFOP_POLARITY) { + fifopPort.setPinState(fifopPin, fifop ? 0 : 1); + } else { + fifopPort.setPinState(fifopPin, fifop ? 1 : 0); + } + } + + private void setRxOverflow() { + if (DEBUG) log("RXFIFO Overflow! Read Pos: " + rxfifoReadPos + " Write Pos: " + rxfifoWritePos); + setFIFOP(true); + setFIFO(false); + } + + private void setFIFO(boolean fifo) { + if (DEBUG) log(getName() + " setting FIFO to " + fifo); + fifoPort.setPinState(fifoPin, fifo ? 1 : 0); + } + + /***************************************************************************** + * External APIs for simulators simulating Radio medium, etc. + * + *****************************************************************************/ public void updateActiveFrequency() { /* INVERTED: f = 5 * (c - 11) + 357 + 0x4000 */ activeFrequency = registers[REG_FSCTRL] - 357 + 2405 - 0x4000; @@ -763,11 +896,13 @@ } public void setRSSI(int power) { + if (DEBUG) log("external setRSSI to: " + power); if (power < -128) { power = -128; } rssi = power; registers[REG_RSSI] = power - RSSI_OFFSET; + updateCCA(); } public int getRSSI() { @@ -799,57 +934,7 @@ return -100; } - private void shrNext() { - if(shrPos == 5) { - // Set SFD high - setSFD(true); - setState(RadioState.TX_FRAME); - } else { - if (listener != null) { - listener.receivedByte(SHR[shrPos]); - } - shrPos++; - cpu.scheduleTimeEventMillis(shrEvent, SYMBOL_PERIOD * 2); - } - } - private void txNext() { - if(txfifoPos <= memory[RAM_TXFIFO]) { - if (listener != null) { - listener.receivedByte((byte)(memory[RAM_TXFIFO + txfifoPos] & 0xFF)); - } - txfifoPos++; - // Two symbol periods to send a byte... - long time = cpu.scheduleTimeEventMillis(sendEvent, SYMBOL_PERIOD * 2); -// log("Scheduling 2 SYMB at: " + time + " getTime(now): " + cpu.getTime()); - } else { - if (DEBUG) log("Completed Transmission."); - status &= ~STATUS_TX_ACTIVE; - setSFD(false); - setState(RadioState.RX_CALIBRATE); - txfifoFlush = true; - } - } - - private void setSymbolEvent(int symbols) { - double period = SYMBOL_PERIOD * symbols; - cpu.scheduleTimeEventMillis(symbolEvent, period); - //log("Set Symbol event: " + period); - } - - private void startOscillator() { - // 1ms crystal startup from datasheet pg12 - cpu.scheduleTimeEventMillis(oscillatorEvent, 1); - } - - private void stopOscillator() { - status &= ~STATUS_XOSC16M_STABLE; - setState(RadioState.POWER_DOWN); - if (DEBUG) log("Oscillator Off."); - // Reset state - setFIFOP(false); - } - public void setRFListener(RFListener rf) { listener = rf; } @@ -918,92 +1003,20 @@ registers[register] = data; } - private void flushRX() { - if (DEBUG) { - log("Flushing RX len = " + rxfifoLen); - } - rxfifoReadPos = 0; - rxfifoWritePos = 0; - rxfifoLen = 0; - setSFD(false); - setFIFOP(false); - } - - // TODO: update any pins here? - private void flushTX() { - txCursor = 0; - } - /* External API for radio mediums - will change to setRSSI only later...*/ public void setCCA(boolean clear) { - if (clear) { - rssi = 0; - } else { - rssi = 127; - } - updateCCA(); + if (DEBUG) log("*** CCA set to: " + clear + " ignored...."); +// if (clear) { +// rssi = 0; +// } else { +// rssi = 127; +// } +// updateCCA(); } - - private void updateCCA() { - boolean oldCCA = cca; - int ccaMux = (registers[REG_IOCFG1] & CCAMUX); - if (ccaMux == CCAMUX_CCA) { - /* TODO: implement a correct "value" of CCA rssi level? */ - cca = (status & STATUS_RSSI_VALID) > 0 && rssi < 50; - } else if (ccaMux == CCAMUX_XOSC16M_STABLE) { - cca = (status & STATUS_XOSC16M_STABLE) > 0; - } - - if (cca != oldCCA) { - setInternalCCA(cca); - } - } - - private void setInternalCCA(boolean clear) { - setCCAPin(clear); - if (DEBUG) log("Internal CCA: " + clear); - } - - - private void setSFD(boolean sfd) { - if( (registers[REG_IOCFG0] & SFD_POLARITY) == SFD_POLARITY) - sfdPort.setPinState(sfdPin, sfd ? 0 : 1); - else - sfdPort.setPinState(sfdPin, sfd ? 1 : 0); - - if (DEBUG) log("SFD: " + sfd + " " + cpu.cycles); - } - - private void setCCAPin(boolean cca) { - if (DEBUG) log("Setting CCA to: " + cca); - if( (registers[REG_IOCFG0] & CCA_POLARITY) == CCA_POLARITY) - ccaPort.setPinState(ccaPin, cca ? 0 : 1); - else - ccaPort.setPinState(ccaPin, cca ? 1 : 0); - } - - private void setFIFOP(boolean fifop) { - fifoP = fifop; - if (DEBUG) log(getName() + " setting FIFOP to " + fifop); - if( (registers[REG_IOCFG0] & FIFOP_POLARITY) == FIFOP_POLARITY) { - fifopPort.setPinState(fifopPin, fifop ? 0 : 1); - } else { - fifopPort.setPinState(fifopPin, fifop ? 1 : 0); - } - } - - private void setFIFO(boolean fifo) { - if (DEBUG) log(getName() + " setting FIFO to " + fifo); - fifoPort.setPinState(fifoPin, fifo ? 1 : 0); - } - - public void setRxOverflow() { - if (DEBUG) log("RXFIFO Overflow! Read Pos: " + rxfifoReadPos + " Write Pos: " + rxfifoWritePos); - setFIFOP(true); - setFIFO(false); - } - + /***************************************************************************** + * Chip APIs + *****************************************************************************/ public String getName() { return "CC2420"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-10-28 09:38:12
|
Revision: 382 http://mspsim.svn.sourceforge.net/mspsim/?rev=382&view=rev Author: joxe Date: 2008-10-28 09:33:52 +0000 (Tue, 28 Oct 2008) Log Message: ----------- removed filter on VREG_OFF when setting CCA pin Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java mspsim/se/sics/mspsim/core/Loggable.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-28 07:59:36 UTC (rev 381) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-28 09:33:52 UTC (rev 382) @@ -976,13 +976,11 @@ } private void setCCAPin(boolean cca) { - if (stateMachine != RadioState.VREG_OFF) { - if (DEBUG) log("Setting CCA to: " + cca); - if( (registers[REG_IOCFG0] & CCA_POLARITY) == CCA_POLARITY) - ccaPort.setPinState(ccaPin, cca ? 0 : 1); - else - ccaPort.setPinState(ccaPin, cca ? 1 : 0); - } + if (DEBUG) log("Setting CCA to: " + cca); + if( (registers[REG_IOCFG0] & CCA_POLARITY) == CCA_POLARITY) + ccaPort.setPinState(ccaPin, cca ? 0 : 1); + else + ccaPort.setPinState(ccaPin, cca ? 1 : 0); } private void setFIFOP(boolean fifop) { Modified: mspsim/se/sics/mspsim/core/Loggable.java =================================================================== --- mspsim/se/sics/mspsim/core/Loggable.java 2008-10-28 07:59:36 UTC (rev 381) +++ mspsim/se/sics/mspsim/core/Loggable.java 2008-10-28 09:33:52 UTC (rev 382) @@ -1,8 +1,43 @@ +/** + * Copyright (c) 2007, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file is part of MSPSim. + * + */ package se.sics.mspsim.core; - import java.io.PrintStream; +/** + * @author joakime + * + */ public interface Loggable { + public void setLogStream(PrintStream out); public void clearLogStream(); -} + +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-10-28 07:59:48
|
Revision: 381 http://mspsim.svn.sourceforge.net/mspsim/?rev=381&view=rev Author: joxe Date: 2008-10-28 07:59:36 +0000 (Tue, 28 Oct 2008) Log Message: ----------- added some updateCCA Modified Paths: -------------- mspsim/scripts/autorun.sc mspsim/se/sics/mspsim/chip/CC2420.java Modified: mspsim/scripts/autorun.sc =================================================================== --- mspsim/scripts/autorun.sc 2008-10-27 22:56:42 UTC (rev 380) +++ mspsim/scripts/autorun.sc 2008-10-28 07:59:36 UTC (rev 381) @@ -1,3 +1,6 @@ # autorun script for MSPSim # - all commands will run after loaded firmware into MSPSim +exec rm log.txt +log CC2420 >log.txt +printcalls >log.txt start Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-27 22:56:42 UTC (rev 380) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-28 07:59:36 UTC (rev 381) @@ -303,9 +303,9 @@ public void execute(long t) { if(DEBUG) log("VREG Started at: " + t + " cyc: " + cpu.cycles + " " + getTime()); - updateCCA(); on = true; setState(RadioState.POWER_DOWN); + updateCCA(); } }; @@ -363,6 +363,7 @@ if (DEBUG) log("VREG Off."); status &= ~(STATUS_RSSI_VALID | STATUS_XOSC16M_STABLE); setMode(MODE_POWER_OFF); + updateCCA(); break; case POWER_DOWN: @@ -370,6 +371,7 @@ rxfifoWritePos = 0; status &= ~(STATUS_RSSI_VALID | STATUS_XOSC16M_STABLE); setMode(MODE_POWER_OFF); + updateCCA(); break; case RX_CALIBRATE: @@ -414,6 +416,7 @@ case IDLE: status &= ~STATUS_RSSI_VALID; setMode(MODE_TXRX_OFF); + updateCCA(); break; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-10-27 22:56:47
|
Revision: 380 http://mspsim.svn.sourceforge.net/mspsim/?rev=380&view=rev Author: nifi Date: 2008-10-27 22:56:42 +0000 (Mon, 27 Oct 2008) Log Message: ----------- added case insensitive and invert match options to 'grep' command Modified Paths: -------------- mspsim/se/sics/mspsim/cli/MiscCommands.java Modified: mspsim/se/sics/mspsim/cli/MiscCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/MiscCommands.java 2008-10-27 22:55:08 UTC (rev 379) +++ mspsim/se/sics/mspsim/cli/MiscCommands.java 2008-10-27 22:56:42 UTC (rev 380) @@ -39,7 +39,6 @@ * $Revision$ */ package se.sics.mspsim.cli; -import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -62,17 +61,34 @@ private Hashtable <String, FileTarget> fileTargets = new Hashtable<String, FileTarget>(); public void setupCommands(final ComponentRegistry registry, CommandHandler handler) { - handler.registerCommand("grep", new BasicLineCommand("print lines matching the specified pattern", "<regexp>") { + handler.registerCommand("grep", new BasicLineCommand("print lines matching the specified pattern", "[-i] [-v] <regexp>") { private PrintStream out; private Pattern pattern; + private boolean isInverted = false; + public int executeCommand(CommandContext context) { + int index = 0; + int flags = 0; + while (index + 1 < context.getArgumentCount()) { + if ("-i".equals(context.getArgument(index))) { + flags |= Pattern.CASE_INSENSITIVE; + } else if ("-v".equals(context.getArgument(index))) { + isInverted = true; + } else { + context.err.println("unknown option: " + context.getArgument(index)); + return 1; + } + index++; + } out = context.out; - pattern = Pattern.compile(context.getArgument(0)); + pattern = Pattern.compile(context.getArgument(index), flags); return 0; } public void lineRead(String line) { - if (pattern.matcher(line).find()) + boolean isMatch = pattern.matcher(line).find(); + if(isMatch ^ isInverted) { out.println(line); + } } public void stopCommand(CommandContext context) { context.exit(0); @@ -125,7 +141,7 @@ handler.registerCommand("files", new BasicCommand("list open files", "") { public int executeCommand(CommandContext context) { for (Iterator<FileTarget> iterator = fileTargets.values().iterator(); iterator.hasNext();) { - FileTarget type = (FileTarget) iterator.next(); + FileTarget type = iterator.next(); context.out.println(type.getName()); } return 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-10-27 22:55:14
|
Revision: 379 http://mspsim.svn.sourceforge.net/mspsim/?rev=379&view=rev Author: nifi Date: 2008-10-27 22:55:08 +0000 (Mon, 27 Oct 2008) Log Message: ----------- stop command chain if any command fails to start Modified Paths: -------------- mspsim/se/sics/mspsim/cli/CommandHandler.java Modified: mspsim/se/sics/mspsim/cli/CommandHandler.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-10-27 19:33:01 UTC (rev 378) +++ mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-10-27 22:55:08 UTC (rev 379) @@ -79,22 +79,30 @@ // TODO: Check if first command is also LineListener and set it up for input!! } // Execute when all is set-up in opposite order... - // TODO if error the command chain should be stopped - for (int i = parts.length - 1; i >= 0; i--) { - try { - int code = commands[i].getCommand().executeCommand(commands[i]); + int index = commands.length - 1; + try { + for (; index >= 0; index--) { + int code = commands[index].getCommand().executeCommand(commands[index]); if (code != 0) { - err.println("command '" + commands[i].getCommandName() + "' failed with error code " + code); + err.println("command '" + commands[index].getCommandName() + "' failed with error code " + code); error = true; + break; } - } catch (Exception e) { - err.println("Error: Command failed: " + e.getMessage()); - e.printStackTrace(err); - error = true; } + } catch (Exception e) { + err.println("Error: Command failed: " + e.getMessage()); + e.printStackTrace(err); + error = true; } if (error) { - // TODO close any started commands + // Stop any commands that have been started + for (index++; index < commands.length; index++) { + Command command = commands[index].getCommand(); + if (command instanceof AsyncCommand && !commands[index].hasExited()) { + AsyncCommand ac = (AsyncCommand) command; + ac.stopCommand(commands[index]); + } + } return 1; } else if (pid >= 0) { synchronized (currentAsyncCommands) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-10-27 19:33:25
|
Revision: 378 http://mspsim.svn.sourceforge.net/mspsim/?rev=378&view=rev Author: joxe Date: 2008-10-27 19:33:01 +0000 (Mon, 27 Oct 2008) Log Message: ----------- fixed CCA handling Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java Added Paths: ----------- mspsim/se/sics/mspsim/core/Loggable.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-27 16:13:22 UTC (rev 377) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-27 19:33:01 UTC (rev 378) @@ -228,7 +228,6 @@ // a flag indicating read/write public static final int FLAG_RAM_READ = 0x20; - private SpiState state = SpiState.WAITING; private int pos; private int address; @@ -243,7 +242,14 @@ private int lastPacketStart; private int zero_symbols; private boolean ramRead = false; - private boolean cca = true; + + /* RSSI is an externally set value of the RSSI for this CC2420 */ + /* low RSSI => CCA = true in normal mode */ + + private int rssi = 0; + private static int RSSI_OFFSET = -45; /* cc2420 datasheet */ + /* current CCA value */ + private boolean cca = false; private int activeFrequency = 0; private int activeChannel = 0; @@ -286,7 +292,7 @@ if(DEBUG) log("Oscillator Stable Event."); setState(RadioState.IDLE); if( (registers[REG_IOCFG1] & CCAMUX) == CCAMUX_XOSC16M_STABLE) { - setInternalCCA(true); + updateCCA(); } else { if(DEBUG) log("CCAMUX != CCA_XOSC16M_STABLE! Not raising CCA"); } @@ -297,7 +303,7 @@ public void execute(long t) { if(DEBUG) log("VREG Started at: " + t + " cyc: " + cpu.cycles + " " + getTime()); - // setCCA(false); + updateCCA(); on = true; setState(RadioState.POWER_DOWN); } @@ -319,7 +325,6 @@ public void execute(long t) { switch(stateMachine) { case RX_CALIBRATE: - setCCA(cca); setState(RadioState.RX_SFD_SEARCH); break; @@ -328,7 +333,6 @@ break; case RX_WAIT: - setCCA(cca); setState(RadioState.RX_SFD_SEARCH); break; } @@ -377,6 +381,7 @@ zero_symbols = 0; // RSSI valid here? status |= STATUS_RSSI_VALID; + updateCCA(); break; case TX_CALIBRATE: @@ -422,9 +427,9 @@ public void receivedByte(byte data) { // Received a byte from the "air" /* CCA not clear if normal mode */ - if(cca) { - setCCA(false); - } +// if(cca) { +// setCCA(false); +// } // Above RX_WAIT => RX_SFD_SEARCH after 8 symbols should make this work without this??? // if (stateMachine == RX_WAIT) { @@ -558,6 +563,7 @@ + " CCAMUX: " + (registers[address] & CCAMUX)); // if( (registers[address] & CCAMUX) == CCA_CCA) // setCCA(false); + updateCCA(); break; } } @@ -753,17 +759,16 @@ return (registers[REG_TXCTRL] & 0x1f); } - private static int RSSI_OFFSET = -45; /* cc2420 datasheet */ - public void setRSSI(int power) { if (power < -128) { power = -128; } + rssi = power; registers[REG_RSSI] = power - RSSI_OFFSET; } public int getRSSI() { - return registers[REG_RSSI] + RSSI_OFFSET; + return rssi; } public int getOutputPower() { @@ -926,15 +931,32 @@ txCursor = 0; } - /* External API for radio mediums */ + /* External API for radio mediums - will change to setRSSI only later...*/ public void setCCA(boolean clear) { - cca = clear; - if (((registers[REG_IOCFG1] & CCAMUX) == CCAMUX_CCA) && - stateMachine.ordinal() > RadioState.IDLE.ordinal()) { - setInternalCCA(clear); + if (clear) { + rssi = 0; + } else { + rssi = 127; } + updateCCA(); } + + private void updateCCA() { + boolean oldCCA = cca; + int ccaMux = (registers[REG_IOCFG1] & CCAMUX); + if (ccaMux == CCAMUX_CCA) { + /* TODO: implement a correct "value" of CCA rssi level? */ + cca = (status & STATUS_RSSI_VALID) > 0 && rssi < 50; + } else if (ccaMux == CCAMUX_XOSC16M_STABLE) { + cca = (status & STATUS_XOSC16M_STABLE) > 0; + } + + if (cca != oldCCA) { + setInternalCCA(cca); + } + } + private void setInternalCCA(boolean clear) { setCCAPin(clear); if (DEBUG) log("Internal CCA: " + clear); @@ -952,6 +974,7 @@ private void setCCAPin(boolean cca) { if (stateMachine != RadioState.VREG_OFF) { + if (DEBUG) log("Setting CCA to: " + cca); if( (registers[REG_IOCFG0] & CCA_POLARITY) == CCA_POLARITY) ccaPort.setPinState(ccaPin, cca ? 0 : 1); else Added: mspsim/se/sics/mspsim/core/Loggable.java =================================================================== --- mspsim/se/sics/mspsim/core/Loggable.java (rev 0) +++ mspsim/se/sics/mspsim/core/Loggable.java 2008-10-27 19:33:01 UTC (rev 378) @@ -0,0 +1,8 @@ +package se.sics.mspsim.core; + +import java.io.PrintStream; + +public interface Loggable { + public void setLogStream(PrintStream out); + public void clearLogStream(); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-10-27 16:13:28
|
Revision: 377 http://mspsim.svn.sourceforge.net/mspsim/?rev=377&view=rev Author: joxe Date: 2008-10-27 16:13:22 +0000 (Mon, 27 Oct 2008) Log Message: ----------- changed behavior of CCA in CC2420 Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-27 13:54:42 UTC (rev 376) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-27 16:13:22 UTC (rev 377) @@ -39,7 +39,6 @@ */ package se.sics.mspsim.chip; -import java.io.PrintStream; import se.sics.mspsim.core.*; import se.sics.mspsim.util.Utils; @@ -144,8 +143,8 @@ public static final int CCAMUX = 0x1F; // CCAMUX values - public static final int CCA_CCA = 0; - public static final int CCA_XOSC16M_STABLE = 24; + public static final int CCAMUX_CCA = 0; + public static final int CCAMUX_XOSC16M_STABLE = 24; // RAM Addresses @@ -244,8 +243,8 @@ private int lastPacketStart; private int zero_symbols; private boolean ramRead = false; - private boolean cca = false; - + private boolean cca = true; + private int activeFrequency = 0; private int activeChannel = 0; @@ -286,8 +285,8 @@ status |= STATUS_XOSC16M_STABLE; if(DEBUG) log("Oscillator Stable Event."); setState(RadioState.IDLE); - if( (registers[REG_IOCFG1] & CCAMUX) == CCA_XOSC16M_STABLE) { - setCCA(true); + if( (registers[REG_IOCFG1] & CCAMUX) == CCAMUX_XOSC16M_STABLE) { + setInternalCCA(true); } else { if(DEBUG) log("CCAMUX != CCA_XOSC16M_STABLE! Not raising CCA"); } @@ -298,7 +297,7 @@ public void execute(long t) { if(DEBUG) log("VREG Started at: " + t + " cyc: " + cpu.cycles + " " + getTime()); - setCCA(false); + // setCCA(false); on = true; setState(RadioState.POWER_DOWN); } @@ -320,7 +319,7 @@ public void execute(long t) { switch(stateMachine) { case RX_CALIBRATE: - setCCA(true); + setCCA(cca); setState(RadioState.RX_SFD_SEARCH); break; @@ -329,7 +328,7 @@ break; case RX_WAIT: - setCCA(true); + setCCA(cca); setState(RadioState.RX_SFD_SEARCH); break; } @@ -422,8 +421,10 @@ */ public void receivedByte(byte data) { // Received a byte from the "air" - if(cca) + /* CCA not clear if normal mode */ + if(cca) { setCCA(false); + } // Above RX_WAIT => RX_SFD_SEARCH after 8 symbols should make this work without this??? // if (stateMachine == RX_WAIT) { @@ -493,7 +494,7 @@ public void dataReceived(USART source, int data) { int oldStatus = status; if (DEBUG) { - log("CC2420 byte received: " + Utils.hex8(data) + + log("byte received: " + Utils.hex8(data) + " (" + ((data >= ' ' && data <= 'Z') ? (char) data : '.') + ')' + " CS: " + chipSelect + " SPI state: " + state + " StateMachine: " + stateMachine); } @@ -916,7 +917,6 @@ rxfifoReadPos = 0; rxfifoWritePos = 0; rxfifoLen = 0; - setCCA(true); setSFD(false); setFIFOP(false); } @@ -926,12 +926,21 @@ txCursor = 0; } + /* External API for radio mediums */ public void setCCA(boolean clear) { cca = clear; + if (((registers[REG_IOCFG1] & CCAMUX) == CCAMUX_CCA) && + stateMachine.ordinal() > RadioState.IDLE.ordinal()) { + setInternalCCA(clear); + } + } + + private void setInternalCCA(boolean clear) { setCCAPin(clear); - if (DEBUG) log("CCA: " + clear); + if (DEBUG) log("Internal CCA: " + clear); } + private void setSFD(boolean sfd) { if( (registers[REG_IOCFG0] & SFD_POLARITY) == SFD_POLARITY) sfdPort.setPinState(sfdPin, sfd ? 0 : 1); @@ -942,10 +951,12 @@ } private void setCCAPin(boolean cca) { - if( (registers[REG_IOCFG0] & CCA_POLARITY) == CCA_POLARITY) - ccaPort.setPinState(ccaPin, cca ? 0 : 1); - else - ccaPort.setPinState(ccaPin, cca ? 1 : 0); + if (stateMachine != RadioState.VREG_OFF) { + if( (registers[REG_IOCFG0] & CCA_POLARITY) == CCA_POLARITY) + ccaPort.setPinState(ccaPin, cca ? 0 : 1); + else + ccaPort.setPinState(ccaPin, cca ? 1 : 0); + } } private void setFIFOP(boolean fifop) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-10-27 13:54:51
|
Revision: 376 http://mspsim.svn.sourceforge.net/mspsim/?rev=376&view=rev Author: joxe Date: 2008-10-27 13:54:42 +0000 (Mon, 27 Oct 2008) Log Message: ----------- added CLI support for starting/stopping logging and added log support for CC2420 Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java mspsim/se/sics/mspsim/chip/SHT11.java mspsim/se/sics/mspsim/chip/TR1001.java mspsim/se/sics/mspsim/cli/AbstractWindowDataHandler.java mspsim/se/sics/mspsim/cli/CommandHandler.java mspsim/se/sics/mspsim/cli/DebugCommands.java mspsim/se/sics/mspsim/cli/FileTarget.java mspsim/se/sics/mspsim/cli/MiscCommands.java mspsim/se/sics/mspsim/cli/ProfilerCommands.java mspsim/se/sics/mspsim/cli/WindowTarget.java mspsim/se/sics/mspsim/core/Chip.java mspsim/se/sics/mspsim/core/MSP430Core.java mspsim/se/sics/mspsim/extutil/jfreechart/LineChart.java mspsim/se/sics/mspsim/extutil/jfreechart/LineSampleChart.java mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java mspsim/se/sics/mspsim/platform/sky/SkyNode.java mspsim/se/sics/mspsim/platform/sky/TelosNode.java mspsim/se/sics/mspsim/util/NetworkConnection.java mspsim/se/sics/mspsim/util/OperatingModeStatistics.java mspsim/se/sics/mspsim/util/StatCommands.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-27 07:22:11 UTC (rev 375) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-27 13:54:42 UTC (rev 376) @@ -39,14 +39,14 @@ */ package se.sics.mspsim.chip; +import java.io.PrintStream; + import se.sics.mspsim.core.*; import se.sics.mspsim.util.Utils; public class CC2420 extends Chip implements USARTListener, RFListener { - public static final boolean DEBUG = false; //true; - - public enum Reg { + public enum Reg { SNOP, SXOSCON, STXCAL, SRXON, /* 0x00 */ STXON, STXONCCA, SRFOFF, SXOSCOFF, /* 0x04 */ SFLUSHRX, SFLUSHTX, SACK, SACKPEND, /* 0x08 */ @@ -65,7 +65,7 @@ RESc, RESd, TXFIFO, RXFIFO }; - public enum SpiState { + public enum SpiState { WAITING, WRITE_REGISTER, READ_REGISTER, RAM_ACCESS, READ_RXFIFO, WRITE_TXFIFO }; @@ -275,30 +275,28 @@ private IOPort sfdPort = null; private int sfdPin; - private int rxLen; private int txCursor; private RFListener listener; + private boolean on; - private MSP430Core cpu; - private TimeEvent oscillatorEvent = new TimeEvent(0) { public void execute(long t) { status |= STATUS_XOSC16M_STABLE; - if(DEBUG) System.out.println("CC2420: Oscillator Stable Event."); + if(DEBUG) log("Oscillator Stable Event."); setState(RadioState.IDLE); if( (registers[REG_IOCFG1] & CCAMUX) == CCA_XOSC16M_STABLE) { setCCA(true); } else { - if(DEBUG) System.out.println("CC2420: CCAMUX != CCA_XOSC16M_STABLE! Not raising CCA"); + if(DEBUG) log("CCAMUX != CCA_XOSC16M_STABLE! Not raising CCA"); } } }; private TimeEvent vregEvent = new TimeEvent(0) { public void execute(long t) { - if(DEBUG) System.out.println("CC2420: VREG Started at: " + t + " cyc: " + + if(DEBUG) log("VREG Started at: " + t + " cyc: " + cpu.cycles + " " + getTime()); setCCA(false); on = true; @@ -338,14 +336,28 @@ } }; + // TODO: super(cpu) and chip autoregister chips into the CPU. + public CC2420(MSP430Core cpu) { + registers[REG_SNOP] = 0; + registers[REG_TXCTRL] = 0xa0ff; + this.cpu = cpu; + setModeNames(MODE_NAMES); + setMode(MODE_POWER_OFF); + fifoP = false; + rxfifoReadPos = 0; + rxfifoWritePos = 0; + + cpu.addChip(this); + } + private boolean setState(RadioState state) { - //if(DEBUG) System.out.println("CC2420: State Transition from " + stateMachine + " to " + state); + //if(DEBUG) log("State Transition from " + stateMachine + " to " + state); stateMachine = state; switch(stateMachine) { case VREG_OFF: - if (DEBUG) System.out.println("CC2420: VREG Off."); + if (DEBUG) log("VREG Off."); status &= ~(STATUS_RSSI_VALID | STATUS_XOSC16M_STABLE); setMode(MODE_POWER_OFF); break; @@ -405,20 +417,6 @@ } - private boolean on; - - public CC2420(MSP430Core cpu) { - registers[REG_SNOP] = 0; - registers[REG_TXCTRL] = 0xa0ff; - this.cpu = cpu; - setModeNames(MODE_NAMES); - setMode(MODE_POWER_OFF); - fifoP = false; - rxfifoReadPos = 0; - rxfifoWritePos = 0; - } - - /* Receive a byte from the radio medium * @see se.sics.mspsim.chip.RFListener#receivedByte(byte) */ @@ -445,7 +443,7 @@ if(data == 0x7A) { // In RX mode, SFD goes high when the SFD is received setSFD(true); - if (DEBUG) System.out.println("CC2420: RX: Preamble/SFD Synchronized."); + if (DEBUG) log("RX: Preamble/SFD Synchronized."); rxread = 0; setState(RadioState.RX_FRAME); } else { @@ -461,13 +459,13 @@ rxfifoLen++; if(rxfifoWritePos == 128) { - if (DEBUG) System.out.println("Wrapped RXFIFO write pos"); + if (DEBUG) log("Wrapped RXFIFO write pos"); rxfifoWritePos = 0; } if(rxread == 0) { rxlen = (int)data; - if (DEBUG) System.out.println("CC2420: RX: Start frame length " + rxlen); + if (DEBUG) log("RX: Start frame length " + rxlen); // FIFO pin goes high after length byte is written to RXFIFO setFIFO(true); } @@ -482,20 +480,20 @@ setFIFOP(true); setSFD(false); lastPacketStart = (rxfifoWritePos + 128 - rxlen) & 127; - if (DEBUG) System.out.println("CC2420: RX: Complete: packetStart: " + + if (DEBUG) log("RX: Complete: packetStart: " + lastPacketStart); setState(RadioState.RX_WAIT); } } } else if (DEBUG) { - System.out.println("*** Ignoring byte from air state: " + stateMachine); + log("*** Ignoring byte from air state: " + stateMachine); } } public void dataReceived(USART source, int data) { int oldStatus = status; if (DEBUG) { - System.out.println("CC2420 byte received: " + Utils.hex8(data) + + log("CC2420 byte received: " + Utils.hex8(data) + " (" + ((data >= ' ' && data <= 'Z') ? (char) data : '.') + ')' + " CS: " + chipSelect + " SPI state: " + state + " StateMachine: " + stateMachine); } @@ -518,7 +516,7 @@ if (address == REG_RXFIFO) { // check read/write??? - // System.out.println("CC2420: Reading RXFIFO!!!"); + // log("Reading RXFIFO!!!"); state = SpiState.READ_RXFIFO; } else if (address == REG_TXFIFO) { state = SpiState.WRITE_TXFIFO; @@ -547,14 +545,14 @@ } if (DEBUG) { - System.out.println("CC2420: wrote to " + Utils.hex8(address) + " = " + log("wrote to " + Utils.hex8(address) + " = " + registers[address]); switch(address) { case REG_IOCFG0: - System.out.println("CC2420: IOCFG0: " + registers[address]); + log("IOCFG0: " + registers[address]); break; case REG_IOCFG1: - System.out.println("CC2420: IOCFG1: SFDMUX " + log("IOCFG1: SFDMUX " + ((registers[address] & SFDMUX) >> SFDMUX) + " CCAMUX: " + (registers[address] & CCAMUX)); // if( (registers[address] & CCAMUX) == CCA_CCA) @@ -573,7 +571,7 @@ } else { source.byteReceived(registers[address] & 0xff); if (DEBUG) { - System.out.println("CC2420: read from " + Utils.hex8(address) + " = " + log("read from " + Utils.hex8(address) + " = " + registers[address]); } state = SpiState.WAITING; @@ -583,14 +581,14 @@ case READ_RXFIFO: if(rxfifoLen == 0) break; - if(DEBUG) System.out.println("CC2420: RXFIFO READ " + rxfifoReadPos + " => " + + if(DEBUG) log("RXFIFO READ " + rxfifoReadPos + " => " + (memory[RAM_RXFIFO + rxfifoReadPos] & 0xFF) ); source.byteReceived( (memory[RAM_RXFIFO + rxfifoReadPos] & 0xFF) ); rxfifoReadPos++; // Set the FIFO pin low if there are no more bytes available in the RXFIFO. if(--rxfifoLen == 0) { - if (DEBUG) System.out.println("Setting FIFO to low (buffer empty)"); + if (DEBUG) log("Setting FIFO to low (buffer empty)"); setFIFO(false); } @@ -603,7 +601,7 @@ // -MT FIFOP is lowered when there are less than IOCFG0:FIFOP_THR bytes in the RXFIFO // If FIFO_THR is greater than the frame length, FIFOP goes low when the first byte is read out. if (fifoP) { - if (DEBUG) System.out.println("*** FIFOP cleared at: " + rxfifoReadPos + + if (DEBUG) log("*** FIFOP cleared at: " + rxfifoReadPos + " lastPacketStartPos: " + lastPacketStart); setFIFOP(false); } @@ -613,7 +611,7 @@ txCursor = 0; txfifoFlush = false; } - if (DEBUG) System.out.println("Writing data: " + data + " to tx: " + txCursor); + if (DEBUG) log("Writing data: " + data + " to tx: " + txCursor); memory[RAM_TXFIFO + txCursor++] = data & 0xff; break; @@ -622,7 +620,7 @@ address = address | (data << 1) & 0x180; ramRead = (data & 0x20) != 0; if (DEBUG) { - System.out.println("CC2420: Address: " + Utils.hex16(address) + + log("Address: " + Utils.hex16(address) + " read: " + ramRead); } pos++; @@ -630,12 +628,12 @@ if (!ramRead) { memory[address++] = data; if (DEBUG && address == RAM_PANID + 2) { - System.out.println("CC2420: Pan ID set to: 0x" + + log("Pan ID set to: 0x" + Utils.hex8(memory[RAM_PANID]) + Utils.hex8(memory[RAM_PANID + 1])); } }else{ - //System.out.println("Read RAM Addr: " + address + " Data: " + memory[address]); + //log("Read RAM Addr: " + address + " Data: " + memory[address]); source.byteReceived(memory[address++]); return; } @@ -652,33 +650,33 @@ private void strobe(int data) { // Resets, on/off of different things... if (DEBUG) { - System.out.println("CC2420: Strobe on: " + Utils.hex8(data) + " => " + Reg.values()[data]); + log("Strobe on: " + Utils.hex8(data) + " => " + Reg.values()[data]); } if( (stateMachine == RadioState.POWER_DOWN) && (data != REG_SXOSCON) ) { - if (DEBUG) System.out.println("CC2420: Got command strobe: " + data + " in POWER_DOWN. Ignoring."); + if (DEBUG) log("Got command strobe: " + data + " in POWER_DOWN. Ignoring."); return; } switch (data) { case REG_SNOP: - if (DEBUG) System.out.println("CC2420: SNOP => " + Utils.hex8(status) + " at " + cpu.cycles); + if (DEBUG) log("SNOP => " + Utils.hex8(status) + " at " + cpu.cycles); break; case REG_SRXON: if(stateMachine == RadioState.IDLE) { setState(RadioState.RX_CALIBRATE); //updateActiveFrequency(); if (DEBUG) { - System.out.println("CC2420: Strobe RX-ON!!!"); + log("Strobe RX-ON!!!"); } }else{ - if (DEBUG) System.out.println("CC2420: WARNING: SRXON when not IDLE"); + if (DEBUG) log("WARNING: SRXON when not IDLE"); } break; case REG_SRFOFF: if (DEBUG) { - System.out.println("CC2420: Strobe RXTX-OFF!!! at " + cpu.cycles); + log("Strobe RXTX-OFF!!! at " + cpu.cycles); } setState(RadioState.IDLE); break; @@ -693,7 +691,7 @@ status |= STATUS_TX_ACTIVE; setState(RadioState.TX_CALIBRATE); // Starting up TX subsystem - indicate that we are in TX mode! - if (DEBUG) System.out.println("CC2420: Strobe STXON - transmit on! at " + cpu.cycles); + if (DEBUG) log("Strobe STXON - transmit on! at " + cpu.cycles); } break; case REG_STXONCCA: @@ -707,9 +705,9 @@ if(cca) { status |= STATUS_TX_ACTIVE; setState(RadioState.TX_CALIBRATE); - if (DEBUG) System.out.println("CC2420: Strobe STXONCCA - transmit on! at " + cpu.cycles); + if (DEBUG) log("Strobe STXONCCA - transmit on! at " + cpu.cycles); }else{ - if (DEBUG) System.out.println("CC2420: STXONCCA Ignored, CCA false"); + if (DEBUG) log("STXONCCA Ignored, CCA false"); } } break; @@ -717,20 +715,20 @@ flushRX(); break; case REG_SFLUSHTX: - if (DEBUG) System.out.println("CC2420: Flushing TXFIFO"); + if (DEBUG) log("Flushing TXFIFO"); flushTX(); break; case REG_SXOSCON: - //System.out.println("CC2420: Strobe Oscillator On"); + //log("Strobe Oscillator On"); startOscillator(); break; case REG_SXOSCOFF: - //System.out.println("CC2420: Strobe Oscillator Off"); + //log("Strobe Oscillator Off"); stopOscillator(); break; default: if (DEBUG) { - System.out.println("Unknown strobe command: " + data); + log("Unknown strobe command: " + data); } break; } @@ -814,9 +812,9 @@ txfifoPos++; // Two symbol periods to send a byte... long time = cpu.scheduleTimeEventMillis(sendEvent, SYMBOL_PERIOD * 2); -// System.out.println("Scheduling 2 SYMB at: " + time + " getTime(now): " + cpu.getTime()); +// log("Scheduling 2 SYMB at: " + time + " getTime(now): " + cpu.getTime()); } else { - if (DEBUG) System.out.println("Completed Transmission."); + if (DEBUG) log("Completed Transmission."); status &= ~STATUS_TX_ACTIVE; setSFD(false); setState(RadioState.RX_CALIBRATE); @@ -827,7 +825,7 @@ private void setSymbolEvent(int symbols) { double period = SYMBOL_PERIOD * symbols; cpu.scheduleTimeEventMillis(symbolEvent, period); - //System.out.println("Set Symbol event: " + period); + //log("Set Symbol event: " + period); } private void startOscillator() { @@ -838,7 +836,7 @@ private void stopOscillator() { status &= ~STATUS_XOSC16M_STABLE; setState(RadioState.POWER_DOWN); - if (DEBUG) System.out.println("CC2420: Oscillator Off."); + if (DEBUG) log("Oscillator Off."); // Reset state setFIFOP(false); } @@ -853,7 +851,7 @@ if(on) { // 0.6ms maximum vreg startup from datasheet pg 13 cpu.scheduleTimeEventMillis(vregEvent, 0.1); - if (DEBUG) System.out.println(getName() + ": Scheduling vregEvent at: cyc = " + cpu.cycles + + if (DEBUG) log(getName() + ": Scheduling vregEvent at: cyc = " + cpu.cycles + " target: " + vregEvent.getTime() + " current: " + cpu.getTime()); } else { this.on = on; @@ -869,7 +867,7 @@ } if (DEBUG) { - System.out.println("CC2420: setting chipSelect: " + chipSelect); + log("setting chipSelect: " + chipSelect); } } @@ -913,7 +911,7 @@ private void flushRX() { if (DEBUG) { - System.out.println("CC2420: Flushing RX len = " + rxfifoLen); + log("Flushing RX len = " + rxfifoLen); } rxfifoReadPos = 0; rxfifoWritePos = 0; @@ -931,7 +929,7 @@ public void setCCA(boolean clear) { cca = clear; setCCAPin(clear); - if (DEBUG) System.out.println("CC2420: CCA: " + clear); + if (DEBUG) log("CCA: " + clear); } private void setSFD(boolean sfd) { @@ -940,7 +938,7 @@ else sfdPort.setPinState(sfdPin, sfd ? 1 : 0); - if (DEBUG) System.out.println("SFD: " + sfd + " " + cpu.cycles); + if (DEBUG) log("SFD: " + sfd + " " + cpu.cycles); } private void setCCAPin(boolean cca) { @@ -952,7 +950,7 @@ private void setFIFOP(boolean fifop) { fifoP = fifop; - if (DEBUG) System.out.println(getName() + " setting FIFOP to " + fifop); + if (DEBUG) log(getName() + " setting FIFOP to " + fifop); if( (registers[REG_IOCFG0] & FIFOP_POLARITY) == FIFOP_POLARITY) { fifopPort.setPinState(fifopPin, fifop ? 0 : 1); } else { @@ -961,12 +959,12 @@ } private void setFIFO(boolean fifo) { - if (DEBUG) System.out.println(getName() + " setting FIFO to " + fifo); + if (DEBUG) log(getName() + " setting FIFO to " + fifo); fifoPort.setPinState(fifoPin, fifo ? 1 : 0); } public void setRxOverflow() { - if (DEBUG) System.out.println("CC2420: RXFIFO Overflow! Read Pos: " + rxfifoReadPos + " Write Pos: " + rxfifoWritePos); + if (DEBUG) log("RXFIFO Overflow! Read Pos: " + rxfifoReadPos + " Write Pos: " + rxfifoWritePos); setFIFOP(true); setFIFO(false); } @@ -989,5 +987,5 @@ "\n SPI State: " + state + "\n"; } - + } // CC2420 Modified: mspsim/se/sics/mspsim/chip/SHT11.java =================================================================== --- mspsim/se/sics/mspsim/chip/SHT11.java 2008-10-27 07:22:11 UTC (rev 375) +++ mspsim/se/sics/mspsim/chip/SHT11.java 2008-10-27 13:54:42 UTC (rev 376) @@ -139,9 +139,11 @@ writePos = 0; writeLen = 3; }}; - + + // TODO: super(cpu) and chip autoregister chips into the CPU. public SHT11(MSP430Core core) { cpu = core; + cpu.addChip(this); } public void setDataPort(IOPort port, int bit) { Modified: mspsim/se/sics/mspsim/chip/TR1001.java =================================================================== --- mspsim/se/sics/mspsim/chip/TR1001.java 2008-10-27 07:22:11 UTC (rev 375) +++ mspsim/se/sics/mspsim/chip/TR1001.java 2008-10-27 13:54:42 UTC (rev 376) @@ -73,7 +73,6 @@ return MODE_MAX; } - @Override public void dataReceived(USART source, int data) { } Modified: mspsim/se/sics/mspsim/cli/AbstractWindowDataHandler.java =================================================================== --- mspsim/se/sics/mspsim/cli/AbstractWindowDataHandler.java 2008-10-27 07:22:11 UTC (rev 375) +++ mspsim/se/sics/mspsim/cli/AbstractWindowDataHandler.java 2008-10-27 13:54:42 UTC (rev 376) @@ -45,7 +45,6 @@ */ public abstract class AbstractWindowDataHandler implements WindowDataHandler { - @Override public void handleCommand(String[] parts) { String cmd = parts[0]; if ("set".equals(cmd)) { Modified: mspsim/se/sics/mspsim/cli/CommandHandler.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-10-27 07:22:11 UTC (rev 375) +++ mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-10-27 13:54:42 UTC (rev 376) @@ -282,7 +282,6 @@ return false; } - @Override public void lineRead(String line) { executeCommand(line, null); } Modified: mspsim/se/sics/mspsim/cli/DebugCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-10-27 07:22:11 UTC (rev 375) +++ mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-10-27 13:54:42 UTC (rev 376) @@ -39,9 +39,8 @@ * $Revision$ */ package se.sics.mspsim.cli; -import javax.swing.MenuSelectionManager; - import se.sics.mspsim.core.CPUMonitor; +import se.sics.mspsim.core.Chip; import se.sics.mspsim.core.MSP430; import se.sics.mspsim.core.MSP430Constants; import se.sics.mspsim.core.Memory; @@ -373,7 +372,35 @@ xmem.writeByte(adr, val & 0xff); return 0; }}); + + ch.registerCommand("loggable", new BasicCommand("list loggable objects", "") { + @Override + public int executeCommand(CommandContext context) { + Chip[] chips = cpu.getChips(); + for (int i = 0; i < chips.length; i++) { + context.out.println(chips[i].getName()); + } + return 0; + } + }); + ch.registerCommand("log", new BasicAsyncCommand("log a loggable object", "<loggable>" ) { + Chip chip = null; + @Override + public int executeCommand(CommandContext context) { + chip = cpu.getChip(context.getArgument(0)); + if (chip == null) { + context.err.println("Can not find loggable: " + context.getArgument(0)); + } + chip.setLogStream(context.out); + return 0; + } + + public void stopCommand(CommandContext context) { + chip.clearLogStream(); + } + }); + } } } Modified: mspsim/se/sics/mspsim/cli/FileTarget.java =================================================================== --- mspsim/se/sics/mspsim/cli/FileTarget.java 2008-10-27 07:22:11 UTC (rev 375) +++ mspsim/se/sics/mspsim/cli/FileTarget.java 2008-10-27 13:54:42 UTC (rev 376) @@ -63,7 +63,6 @@ /* (non-Javadoc) * @see se.sics.mspsim.cli.LineListener#lineRead(java.lang.String) */ - @Override public void lineRead(String line) { if (line == null) { try { Modified: mspsim/se/sics/mspsim/cli/MiscCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/MiscCommands.java 2008-10-27 07:22:11 UTC (rev 375) +++ mspsim/se/sics/mspsim/cli/MiscCommands.java 2008-10-27 13:54:42 UTC (rev 376) @@ -258,7 +258,6 @@ return 0; } - @Override public void stopCommand(CommandContext context) { isRunning = false; context.err.println("[repeat exit: " + commandLine + ']'); Modified: mspsim/se/sics/mspsim/cli/ProfilerCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/ProfilerCommands.java 2008-10-27 07:22:11 UTC (rev 375) +++ mspsim/se/sics/mspsim/cli/ProfilerCommands.java 2008-10-27 13:54:42 UTC (rev 376) @@ -105,7 +105,6 @@ profiler.setLogger(context.out); return 0; } - @Override public void stopCommand(CommandContext context) { Profiler profiler = cpu.getProfiler(); if (profiler != null) { Modified: mspsim/se/sics/mspsim/cli/WindowTarget.java =================================================================== --- mspsim/se/sics/mspsim/cli/WindowTarget.java 2008-10-27 07:22:11 UTC (rev 375) +++ mspsim/se/sics/mspsim/cli/WindowTarget.java 2008-10-27 13:54:42 UTC (rev 376) @@ -27,7 +27,6 @@ targetName = name; } - @Override public void lineRead(final String line) { if (line != null && window != null) { SwingUtilities.invokeLater(new Runnable() { Modified: mspsim/se/sics/mspsim/core/Chip.java =================================================================== --- mspsim/se/sics/mspsim/core/Chip.java 2008-10-27 07:22:11 UTC (rev 375) +++ mspsim/se/sics/mspsim/core/Chip.java 2008-10-27 13:54:42 UTC (rev 376) @@ -39,17 +39,21 @@ * $Revision$ */ package se.sics.mspsim.core; +import java.io.PrintStream; + import se.sics.mspsim.util.Utils; /** * @author Joakim * */ -public abstract class Chip { +public abstract class Chip implements Loggable { private OperatingModeListener[] omListeners; private String[] modeNames = null; private int mode; + private PrintStream log; + protected boolean DEBUG = false; public void addOperatingModeListener(OperatingModeListener listener) { omListeners = (OperatingModeListener[]) Utils.add(OperatingModeListener.class, omListeners, listener); @@ -112,4 +116,22 @@ public String chipinfo() { return "* no info"; } + + /* Loggable */ + public void clearLogStream() { + log = null; + DEBUG = false; + } + + public void setLogStream(PrintStream out) { + log = out; + DEBUG = true; + } + + public void log(String msg) { + if (log != null) { + log.println(getName() + ": " + msg); + } + } + } Modified: mspsim/se/sics/mspsim/core/MSP430Core.java =================================================================== --- mspsim/se/sics/mspsim/core/MSP430Core.java 2008-10-27 07:22:11 UTC (rev 375) +++ mspsim/se/sics/mspsim/core/MSP430Core.java 2008-10-27 13:54:42 UTC (rev 376) @@ -40,6 +40,8 @@ */ package se.sics.mspsim.core; +import java.util.ArrayList; + import se.sics.mspsim.util.Utils; /** @@ -114,6 +116,7 @@ private long nextCycleEventCycles; private BasicClockModule bcs; + private ArrayList<Chip> chips = new ArrayList<Chip>(); public MSP430Core(int type) { // Ignore type for now... @@ -248,6 +251,32 @@ // } } + public void addChip(Chip chip) { + chips.add(chip); + } + + public Chip getChip(String name) { + for(Chip chip : chips) { + if (name.equals(chip.getName())) { + return chip; + } + } + return null; + } + + public Chip getChip(Class<? extends Chip> type) { + for(Chip chip : chips) { + if (type.isInstance(chip)) { + return chip; + } + } + return null; + } + + public Chip[] getChips() { + return (Chip[]) chips.toArray(new Chip[chips.size()]); + } + public void setBreakPoint(int address, CPUMonitor mon) { breakPoints[address] = mon; } Modified: mspsim/se/sics/mspsim/extutil/jfreechart/LineChart.java =================================================================== --- mspsim/se/sics/mspsim/extutil/jfreechart/LineChart.java 2008-10-27 07:22:11 UTC (rev 375) +++ mspsim/se/sics/mspsim/extutil/jfreechart/LineChart.java 2008-10-27 13:54:42 UTC (rev 376) @@ -88,7 +88,6 @@ panel.add(chartPanel, BorderLayout.CENTER); } - @Override public JComponent getComponent() { return panel; } @@ -119,7 +118,6 @@ } int point = 0; - @Override public void lineRead(String line) { String parts[] = line.trim().split(" "); while (parts.length > getDataSeriesCount()) { Modified: mspsim/se/sics/mspsim/extutil/jfreechart/LineSampleChart.java =================================================================== --- mspsim/se/sics/mspsim/extutil/jfreechart/LineSampleChart.java 2008-10-27 07:22:11 UTC (rev 375) +++ mspsim/se/sics/mspsim/extutil/jfreechart/LineSampleChart.java 2008-10-27 13:54:42 UTC (rev 376) @@ -59,7 +59,6 @@ return panel; } - @Override public void lineRead(String line) { String parts[] = line.trim().split(" "); dataSeries.clear(); Modified: mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java 2008-10-27 07:22:11 UTC (rev 375) +++ mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java 2008-10-27 13:54:42 UTC (rev 376) @@ -5,6 +5,7 @@ import se.sics.mspsim.core.IOPort; import se.sics.mspsim.core.IOUnit; import se.sics.mspsim.core.PortListener; +import se.sics.mspsim.core.USART; import se.sics.mspsim.core.USARTListener; import se.sics.mspsim.platform.GenericNode; import se.sics.mspsim.util.ELF; @@ -93,6 +94,21 @@ unit = cpu.getIOUnit("Port 2"); if (unit instanceof IOPort) { port2 = (IOPort) unit; + } + + IOUnit usart0 = cpu.getIOUnit("USART 0"); + if (usart0 instanceof USART) { + radio = new CC2420(cpu); + radio.setCCAPort(port1, CC2420_CCA); + radio.setFIFOPPort(port1, CC2420_FIFOP); + radio.setFIFOPort(port1, CC2420_FIFO); + + ((USART) usart0).setUSARTListener(this); + port4 = (IOPort) cpu.getIOUnit("Port 4"); + if (port4 != null) { + port4.setPortListener(this); + radio.setSFDPort(port4, CC2420_SFD); + } } } Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-10-27 07:22:11 UTC (rev 375) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-10-27 13:54:42 UTC (rev 376) @@ -105,22 +105,8 @@ public void setupNodePorts() { super.setupNodePorts(); - - IOUnit usart0 = cpu.getIOUnit("USART 0"); - if (usart0 instanceof USART) { - radio = new CC2420(cpu); - radio.setCCAPort(port1, CC2420_CCA); - radio.setFIFOPPort(port1, CC2420_FIFOP); - radio.setFIFOPort(port1, CC2420_FIFO); - if (flashFile != null) { - setFlash(new FileM25P80(cpu, flashFile)); - } - ((USART) usart0).setUSARTListener(this); - port4 = (IOPort) cpu.getIOUnit("Port 4"); - if (port4 != null) { - port4.setPortListener(this); - radio.setSFDPort(port4, CC2420_SFD); - } + if (flashFile != null) { + setFlash(new FileM25P80(cpu, flashFile)); } } Modified: mspsim/se/sics/mspsim/platform/sky/TelosNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/TelosNode.java 2008-10-27 07:22:11 UTC (rev 375) +++ mspsim/se/sics/mspsim/platform/sky/TelosNode.java 2008-10-27 13:54:42 UTC (rev 376) @@ -108,38 +108,10 @@ } public void setupNodePorts(boolean loadFlash) { - IOUnit unit = cpu.getIOUnit("Port 5"); - if (unit instanceof IOPort) { - port5 = (IOPort) unit; - port5.setPortListener(this); + super.setupNodePorts(); + if (loadFlash) { + flash = new FileAT45DB(cpu, flashFile); } - - unit = cpu.getIOUnit("Port 1"); - if (unit instanceof IOPort) { - port1 = (IOPort) unit; - } - - unit = cpu.getIOUnit("Port 2"); - if (unit instanceof IOPort) { - port2 = (IOPort) unit; - } - - IOUnit usart0 = cpu.getIOUnit("USART 0"); - if (usart0 instanceof USART) { - radio = new CC2420(cpu); - radio.setCCAPort(port1, CC2420_CCA); - radio.setFIFOPPort(port1, CC2420_FIFOP); - radio.setFIFOPort(port1, CC2420_FIFO); - if (loadFlash) { - flash = new FileAT45DB(cpu, flashFile); - } - ((USART) usart0).setUSARTListener(this); - port4 = (IOPort) cpu.getIOUnit("Port 4"); - if (port4 != null && port4 instanceof IOPort) { - port4.setPortListener(this); - radio.setSFDPort(port4, CC2420_SFD); - } - } } public void setupNode() { Modified: mspsim/se/sics/mspsim/util/NetworkConnection.java =================================================================== --- mspsim/se/sics/mspsim/util/NetworkConnection.java 2008-10-27 07:22:11 UTC (rev 375) +++ mspsim/se/sics/mspsim/util/NetworkConnection.java 2008-10-27 13:54:42 UTC (rev 376) @@ -245,7 +245,6 @@ return socket == null; } - @Override public void run() { if (DEBUG) System.out.println("NetworkConnection: Started connection thread..."); try { Modified: mspsim/se/sics/mspsim/util/OperatingModeStatistics.java =================================================================== --- mspsim/se/sics/mspsim/util/OperatingModeStatistics.java 2008-10-27 07:22:11 UTC (rev 375) +++ mspsim/se/sics/mspsim/util/OperatingModeStatistics.java 2008-10-27 13:54:42 UTC (rev 376) @@ -168,7 +168,6 @@ Arrays.fill(this.lastCycles, cpu.cycles); } - @Override public int getModeMax() { return entry.chip.getModeMax(); } Modified: mspsim/se/sics/mspsim/util/StatCommands.java =================================================================== --- mspsim/se/sics/mspsim/util/StatCommands.java 2008-10-27 07:22:11 UTC (rev 375) +++ mspsim/se/sics/mspsim/util/StatCommands.java 2008-10-27 13:54:42 UTC (rev 376) @@ -61,7 +61,6 @@ this.statistics = statistics; } - @Override public void setupCommands(ComponentRegistry registry, CommandHandler handler) { handler.registerCommand("chipinfo", new BasicCommand("show information about specified chip", "[chips...]") { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-10-27 07:22:14
|
Revision: 375 http://mspsim.svn.sourceforge.net/mspsim/?rev=375&view=rev Author: joxe Date: 2008-10-27 07:22:11 +0000 (Mon, 27 Oct 2008) Log Message: ----------- set RSSI not valid and no osc when in POWER_DOWN mode Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-26 21:24:37 UTC (rev 374) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-27 07:22:11 UTC (rev 375) @@ -346,12 +346,14 @@ case VREG_OFF: if (DEBUG) System.out.println("CC2420: VREG Off."); + status &= ~(STATUS_RSSI_VALID | STATUS_XOSC16M_STABLE); setMode(MODE_POWER_OFF); break; case POWER_DOWN: rxfifoReadPos = 0; rxfifoWritePos = 0; + status &= ~(STATUS_RSSI_VALID | STATUS_XOSC16M_STABLE); setMode(MODE_POWER_OFF); break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-10-26 21:26:11
|
Revision: 374 http://mspsim.svn.sourceforge.net/mspsim/?rev=374&view=rev Author: joxe Date: 2008-10-26 21:24:37 +0000 (Sun, 26 Oct 2008) Log Message: ----------- made enums of state machine Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-26 19:30:40 UTC (rev 373) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-26 21:24:37 UTC (rev 374) @@ -172,6 +172,24 @@ }; // State Machine - Datasheet Figure 25 page 44 + public enum RadioState { + VREG_OFF, // -1; + POWER_DOWN, // 0; + IDLE, // 1; + RX_CALIBRATE, // 2; + RX_SFD_SEARCH, // 3; + RX_WAIT, // 14; + RX_FRAME, // 16; + RX_OVERFLOW, // 17; + TX_CALIBRATE, // 32; + TX_PREAMBLE, // 34; + TX_FRAME, // 37; + TX_ACK_CALIBRATE, // 48; + TX_ACK_PREABLE, // 49; + TX_ACK, // 52; + TX_UNDERFLOW// 56; + }; + public static final int STATE_VREG_OFF = -1; public static final int STATE_POWER_DOWN = 0; public static final int STATE_IDLE = 1; @@ -198,7 +216,7 @@ public static final int DESTINATION_ADDRESS_MODE = 0x30; public static final int SOURCE_ADDRESS_MODE = 0x3; - private int stateMachine = STATE_VREG_OFF; + private RadioState stateMachine = RadioState.VREG_OFF; // 802.15.4 symbol period in ms public static final double SYMBOL_PERIOD = 0.016; // 16 us @@ -269,7 +287,7 @@ public void execute(long t) { status |= STATUS_XOSC16M_STABLE; if(DEBUG) System.out.println("CC2420: Oscillator Stable Event."); - setState(STATE_IDLE); + setState(RadioState.IDLE); if( (registers[REG_IOCFG1] & CCAMUX) == CCA_XOSC16M_STABLE) { setCCA(true); } else { @@ -284,7 +302,7 @@ cpu.cycles + " " + getTime()); setCCA(false); on = true; - setState(STATE_POWER_DOWN); + setState(RadioState.POWER_DOWN); } }; @@ -303,52 +321,52 @@ private TimeEvent symbolEvent = new TimeEvent(0) { public void execute(long t) { switch(stateMachine) { - case STATE_RX_CALIBRATE: + case RX_CALIBRATE: setCCA(true); - setState(STATE_RX_SFD_SEARCH); + setState(RadioState.RX_SFD_SEARCH); break; - case STATE_TX_CALIBRATE: - setState(STATE_TX_PREAMBLE); + case TX_CALIBRATE: + setState(RadioState.TX_PREAMBLE); break; - case STATE_RX_WAIT: + case RX_WAIT: setCCA(true); - setState(STATE_RX_SFD_SEARCH); + setState(RadioState.RX_SFD_SEARCH); break; } } }; - private boolean setState(int state) { + private boolean setState(RadioState state) { //if(DEBUG) System.out.println("CC2420: State Transition from " + stateMachine + " to " + state); stateMachine = state; switch(stateMachine) { - case STATE_VREG_OFF: + case VREG_OFF: if (DEBUG) System.out.println("CC2420: VREG Off."); setMode(MODE_POWER_OFF); break; - case STATE_POWER_DOWN: + case POWER_DOWN: rxfifoReadPos = 0; rxfifoWritePos = 0; setMode(MODE_POWER_OFF); break; - case STATE_RX_CALIBRATE: + case RX_CALIBRATE: setSymbolEvent(12); setMode(MODE_RX_ON); break; - case STATE_RX_SFD_SEARCH: + case RX_SFD_SEARCH: zero_symbols = 0; // RSSI valid here? status |= STATUS_RSSI_VALID; break; - case STATE_TX_CALIBRATE: + case TX_CALIBRATE: /* 12 symbols calibration, and one byte's wait since we deliver immediately * to listener when after calibration? */ @@ -356,7 +374,7 @@ setMode(MODE_TXRX_ON); break; - case STATE_TX_PREAMBLE: + case TX_PREAMBLE: shrPos = 0; SHR[0] = 0; SHR[1] = 0; @@ -366,16 +384,16 @@ shrNext(); break; - case STATE_TX_FRAME: + case TX_FRAME: txfifoPos = 0; txNext(); break; - case STATE_RX_WAIT: + case RX_WAIT: setSymbolEvent(8); break; - case STATE_IDLE: + case IDLE: status &= ~STATUS_RSSI_VALID; setMode(MODE_TXRX_OFF); break; @@ -408,11 +426,11 @@ setCCA(false); // Above RX_WAIT => RX_SFD_SEARCH after 8 symbols should make this work without this??? -// if (stateMachine == STATE_RX_WAIT) { -// setState(STATE_RX_SFD_SEARCH); +// if (stateMachine == RX_WAIT) { +// setState(RX_SFD_SEARCH); // } - if(stateMachine == STATE_RX_SFD_SEARCH) { + if(stateMachine == RadioState.RX_SFD_SEARCH) { // Look for the preamble (4 zero bytes) followed by the SFD byte 0x7A if(data == 0) { // Count zero bytes @@ -427,13 +445,13 @@ setSFD(true); if (DEBUG) System.out.println("CC2420: RX: Preamble/SFD Synchronized."); rxread = 0; - setState(STATE_RX_FRAME); + setState(RadioState.RX_FRAME); } else { zero_symbols = 0; } } - } else if(stateMachine == STATE_RX_FRAME) { + } else if(stateMachine == RadioState.RX_FRAME) { if(rxfifoLen == 128) { setRxOverflow(); }else{ @@ -464,7 +482,7 @@ lastPacketStart = (rxfifoWritePos + 128 - rxlen) & 127; if (DEBUG) System.out.println("CC2420: RX: Complete: packetStart: " + lastPacketStart); - setState(STATE_RX_WAIT); + setState(RadioState.RX_WAIT); } } } else if (DEBUG) { @@ -480,7 +498,7 @@ " CS: " + chipSelect + " SPI state: " + state + " StateMachine: " + stateMachine); } - if ( (stateMachine != STATE_VREG_OFF) && chipSelect) { + if ( (stateMachine != RadioState.VREG_OFF) && chipSelect) { switch(state) { case WAITING: @@ -635,8 +653,8 @@ System.out.println("CC2420: Strobe on: " + Utils.hex8(data) + " => " + Reg.values()[data]); } - if( (stateMachine == STATE_POWER_DOWN) && (data != REG_SXOSCON) ) { - if (DEBUG) System.out.println("CC2420: Got command strobe: " + data + " in STATE_POWER_DOWN. Ignoring."); + if( (stateMachine == RadioState.POWER_DOWN) && (data != REG_SXOSCON) ) { + if (DEBUG) System.out.println("CC2420: Got command strobe: " + data + " in POWER_DOWN. Ignoring."); return; } @@ -645,8 +663,8 @@ if (DEBUG) System.out.println("CC2420: SNOP => " + Utils.hex8(status) + " at " + cpu.cycles); break; case REG_SRXON: - if(stateMachine == STATE_IDLE) { - setState(STATE_RX_CALIBRATE); + if(stateMachine == RadioState.IDLE) { + setState(RadioState.RX_CALIBRATE); //updateActiveFrequency(); if (DEBUG) { System.out.println("CC2420: Strobe RX-ON!!!"); @@ -660,18 +678,18 @@ if (DEBUG) { System.out.println("CC2420: Strobe RXTX-OFF!!! at " + cpu.cycles); } - setState(STATE_IDLE); + setState(RadioState.IDLE); break; case REG_STXON: // State transition valid from IDLE state or all RX states - if( (stateMachine == STATE_IDLE) || - (stateMachine == STATE_RX_CALIBRATE) || - (stateMachine == STATE_RX_SFD_SEARCH) || - (stateMachine == STATE_RX_FRAME) || - (stateMachine == STATE_RX_OVERFLOW) || - (stateMachine == STATE_RX_WAIT)) { + if( (stateMachine == RadioState.IDLE) || + (stateMachine == RadioState.RX_CALIBRATE) || + (stateMachine == RadioState.RX_SFD_SEARCH) || + (stateMachine == RadioState.RX_FRAME) || + (stateMachine == RadioState.RX_OVERFLOW) || + (stateMachine == RadioState.RX_WAIT)) { status |= STATUS_TX_ACTIVE; - setState(STATE_TX_CALIBRATE); + setState(RadioState.TX_CALIBRATE); // Starting up TX subsystem - indicate that we are in TX mode! if (DEBUG) System.out.println("CC2420: Strobe STXON - transmit on! at " + cpu.cycles); } @@ -679,14 +697,14 @@ case REG_STXONCCA: // Only valid from all RX states, // since CCA requires ??(look this up) receive symbol periods to be valid - if( (stateMachine == STATE_RX_CALIBRATE) || - (stateMachine == STATE_RX_SFD_SEARCH) || - (stateMachine == STATE_RX_FRAME) || - (stateMachine == STATE_RX_OVERFLOW) || - (stateMachine == STATE_RX_WAIT)) { + if( (stateMachine == RadioState.RX_CALIBRATE) || + (stateMachine == RadioState.RX_SFD_SEARCH) || + (stateMachine == RadioState.RX_FRAME) || + (stateMachine == RadioState.RX_OVERFLOW) || + (stateMachine == RadioState.RX_WAIT)) { if(cca) { status |= STATUS_TX_ACTIVE; - setState(STATE_TX_CALIBRATE); + setState(RadioState.TX_CALIBRATE); if (DEBUG) System.out.println("CC2420: Strobe STXONCCA - transmit on! at " + cpu.cycles); }else{ if (DEBUG) System.out.println("CC2420: STXONCCA Ignored, CCA false"); @@ -776,7 +794,7 @@ if(shrPos == 5) { // Set SFD high setSFD(true); - setState(STATE_TX_FRAME); + setState(RadioState.TX_FRAME); } else { if (listener != null) { listener.receivedByte(SHR[shrPos]); @@ -799,7 +817,7 @@ if (DEBUG) System.out.println("Completed Transmission."); status &= ~STATUS_TX_ACTIVE; setSFD(false); - setState(STATE_RX_CALIBRATE); + setState(RadioState.RX_CALIBRATE); txfifoFlush = true; } } @@ -817,7 +835,7 @@ private void stopOscillator() { status &= ~STATUS_XOSC16M_STABLE; - setState(STATE_POWER_DOWN); + setState(RadioState.POWER_DOWN); if (DEBUG) System.out.println("CC2420: Oscillator Off."); // Reset state setFIFOP(false); @@ -837,7 +855,7 @@ " target: " + vregEvent.getTime() + " current: " + cpu.getTime()); } else { this.on = on; - setState(STATE_VREG_OFF); + setState(RadioState.VREG_OFF); } //this.on = on; } @@ -965,6 +983,8 @@ "\n RSSI_Valid: " + ((status & STATUS_RSSI_VALID) > 0) + "\n CCA: " + cca + "\n FIFOP Polarity: " + ((registers[REG_IOCFG0] & FIFOP_POLARITY) == FIFOP_POLARITY) + + "\n Radio State: " + stateMachine + + "\n SPI State: " + state + "\n"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-10-26 19:30:46
|
Revision: 373 http://mspsim.svn.sourceforge.net/mspsim/?rev=373&view=rev Author: joxe Date: 2008-10-26 19:30:40 +0000 (Sun, 26 Oct 2008) Log Message: ----------- fixed autorun script that is executed at start and after firmware load Modified Paths: -------------- mspsim/se/sics/mspsim/cli/CommandParser.java mspsim/se/sics/mspsim/platform/GenericNode.java mspsim/se/sics/mspsim/platform/esb/ESBNode.java mspsim/se/sics/mspsim/platform/sky/SkyNode.java mspsim/se/sics/mspsim/platform/sky/TelosNode.java Added Paths: ----------- mspsim/scripts/autorun.sc Added: mspsim/scripts/autorun.sc =================================================================== --- mspsim/scripts/autorun.sc (rev 0) +++ mspsim/scripts/autorun.sc 2008-10-26 19:30:40 UTC (rev 373) @@ -0,0 +1,3 @@ +# autorun script for MSPSim +# - all commands will run after loaded firmware into MSPSim +start Modified: mspsim/se/sics/mspsim/cli/CommandParser.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandParser.java 2008-10-26 17:46:00 UTC (rev 372) +++ mspsim/se/sics/mspsim/cli/CommandParser.java 2008-10-26 19:30:40 UTC (rev 373) @@ -62,6 +62,10 @@ } public static String[][] parseLine(String line, boolean handlePipes, boolean handleRedirect) { + if (line.charAt(0) == '#') { + return null; + } + ArrayList<String[]> list = new ArrayList<String[]>(); ArrayList<String> args = new ArrayList<String>(); StringBuilder sb = null; Modified: mspsim/se/sics/mspsim/platform/GenericNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/GenericNode.java 2008-10-26 17:46:00 UTC (rev 372) +++ mspsim/se/sics/mspsim/platform/GenericNode.java 2008-10-26 19:30:40 UTC (rev 373) @@ -122,6 +122,15 @@ System.out.println("-----------------------------------------------"); System.out.println("MSPSim " + MSP430Constants.VERSION + " starting firmware: " + firmwareFile); System.out.println("-----------------------------------------------"); + + String script = config.getProperty("autorun"); + if (script != null) { + CommandHandler ch = (CommandHandler) registry.getComponent("commandHandler"); + System.out.println("Autoloading script: " + script); + if (ch != null) { + ch.lineRead("source " + script); + } + } } public void setup(ConfigManager config) throws IOException { @@ -144,8 +153,7 @@ // Monitor execution cpu.setMonitorExec(true); - //cpu.setDebug(true); - + setupNode(); registry.start(); @@ -206,7 +214,7 @@ registry.registerComponent("mapTable", map); return elf; } - + // A step that will break out of breakpoints! public void step(int nr) { if (!cpu.isRunning()) { Modified: mspsim/se/sics/mspsim/platform/esb/ESBNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2008-10-26 17:46:00 UTC (rev 372) +++ mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2008-10-26 19:30:40 UTC (rev 373) @@ -192,8 +192,11 @@ if (config.getProperty("nogui") == null) { config.setProperty("nogui", "false"); } + /* Ensure auto-run of a start script */ + if (config.getProperty("autorun") == null) { + config.setProperty("autorun", "scripts/autorun.sc"); + } node.setupArgs(config); - node.start(); } } Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-10-26 17:46:00 UTC (rev 372) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-10-26 19:30:40 UTC (rev 373) @@ -90,7 +90,7 @@ flash.dataReceived(source, data); /* if nothing selected, just write back a random byte to these devs */ if (!radio.getChipSelect() && !flash.getChipSelect()) { -// source.byteReceived(0); + source.byteReceived(0); } } @@ -201,10 +201,12 @@ if (config.getProperty("nogui") == null) { config.setProperty("nogui", "false"); } + /* Ensure auto-run of a start script */ + if (config.getProperty("autorun") == null) { + config.setProperty("autorun", "scripts/autorun.sc"); + } + node.setupArgs(config); - if (config.getProperty("stop") == null) { - node.start(); - } } } Modified: mspsim/se/sics/mspsim/platform/sky/TelosNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/TelosNode.java 2008-10-26 17:46:00 UTC (rev 372) +++ mspsim/se/sics/mspsim/platform/sky/TelosNode.java 2008-10-26 19:30:40 UTC (rev 373) @@ -209,6 +209,9 @@ ArgumentManager config = new ArgumentManager(); config.handleArguments(args); node.setup(config); - node.start(); + /* Ensure auto-run of a start script */ + if (config.getProperty("autorun") == null) { + config.setProperty("autorun", "scripts/autorun.sc"); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-10-26 17:46:06
|
Revision: 372 http://mspsim.svn.sourceforge.net/mspsim/?rev=372&view=rev Author: joxe Date: 2008-10-26 17:46:00 +0000 (Sun, 26 Oct 2008) Log Message: ----------- improved operation mode handling on CC2420 Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-26 14:47:05 UTC (rev 371) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-26 17:46:00 UTC (rev 372) @@ -46,6 +46,31 @@ public static final boolean DEBUG = false; //true; + public enum Reg { + SNOP, SXOSCON, STXCAL, SRXON, /* 0x00 */ + STXON, STXONCCA, SRFOFF, SXOSCOFF, /* 0x04 */ + SFLUSHRX, SFLUSHTX, SACK, SACKPEND, /* 0x08 */ + SRXDEC, STXENC, SAES, foo, /* 0x0c */ + MAIN, MDMCTRL0, MDMCTRL1, RSSI, /* 0x10 */ + SYNCWORD, TXCTRL, RXCTRL0, RXCTRL1, /* 0x14 */ + FSCTRL, SECCTRL0, SECCTRL1, BATTMON, /* 0x18 */ + IOCFG0, IOCFG1, MANFIDL, MANFIDH, /* 0x1c */ + FSMTC, MANAND, MANOR, AGCCTRL, /* 0x20 */ + AGCTST0, AGCTST1, AGCTST2, FSTST0, /* 0x24 */ + FSTST1, FSTST2, FSTST3, RXBPFTST, /* 0x28 */ + FSMSTATE, ADCTST, DACTST, TOPTST, + RESERVED, RES1, RES2, RES3, /* 0x30 */ + RES4, RES5, RES6, RES7, + RES8, RES9, RESa, RESb, + RESc, RESd, TXFIFO, RXFIFO + }; + + public enum SpiState { + WAITING, WRITE_REGISTER, READ_REGISTER, RAM_ACCESS, + READ_RXFIFO, WRITE_TXFIFO + }; + + public static final int REG_SNOP = 0x00; public static final int REG_SXOSCON = 0x01; public static final int REG_STXCAL = 0x02; @@ -186,8 +211,6 @@ // a flag indicating read/write public static final int FLAG_RAM_READ = 0x20; - public enum SpiState { WAITING, WRITE_REGISTER, READ_REGISTER, RAM_ACCESS, - READ_RXFIFO, WRITE_TXFIFO}; private SpiState state = SpiState.WAITING; private int pos; @@ -305,15 +328,18 @@ case STATE_VREG_OFF: if (DEBUG) System.out.println("CC2420: VREG Off."); + setMode(MODE_POWER_OFF); break; case STATE_POWER_DOWN: rxfifoReadPos = 0; rxfifoWritePos = 0; + setMode(MODE_POWER_OFF); break; case STATE_RX_CALIBRATE: setSymbolEvent(12); + setMode(MODE_RX_ON); break; case STATE_RX_SFD_SEARCH: @@ -327,6 +353,7 @@ * to listener when after calibration? */ setSymbolEvent(12 + 2); + setMode(MODE_TXRX_ON); break; case STATE_TX_PREAMBLE: @@ -350,6 +377,7 @@ case STATE_IDLE: status &= ~STATUS_RSSI_VALID; + setMode(MODE_TXRX_OFF); break; } @@ -604,7 +632,7 @@ private void strobe(int data) { // Resets, on/off of different things... if (DEBUG) { - System.out.println("CC2420: Strobe on: " + Utils.hex8(data)); + System.out.println("CC2420: Strobe on: " + Utils.hex8(data) + " => " + Reg.values()[data]); } if( (stateMachine == STATE_POWER_DOWN) && (data != REG_SXOSCON) ) { @@ -623,7 +651,6 @@ if (DEBUG) { System.out.println("CC2420: Strobe RX-ON!!!"); } - setMode(MODE_RX_ON); }else{ if (DEBUG) System.out.println("CC2420: WARNING: SRXON when not IDLE"); } @@ -634,7 +661,6 @@ System.out.println("CC2420: Strobe RXTX-OFF!!! at " + cpu.cycles); } setState(STATE_IDLE); - setMode(MODE_TXRX_OFF); break; case REG_STXON: // State transition valid from IDLE state or all RX states @@ -647,7 +673,6 @@ status |= STATUS_TX_ACTIVE; setState(STATE_TX_CALIBRATE); // Starting up TX subsystem - indicate that we are in TX mode! - setMode(MODE_TXRX_ON); if (DEBUG) System.out.println("CC2420: Strobe STXON - transmit on! at " + cpu.cycles); } break; @@ -662,7 +687,6 @@ if(cca) { status |= STATUS_TX_ACTIVE; setState(STATE_TX_CALIBRATE); - setMode(MODE_TXRX_ON); if (DEBUG) System.out.println("CC2420: Strobe STXONCCA - transmit on! at " + cpu.cycles); }else{ if (DEBUG) System.out.println("CC2420: STXONCCA Ignored, CCA false"); @@ -776,7 +800,6 @@ status &= ~STATUS_TX_ACTIVE; setSFD(false); setState(STATE_RX_CALIBRATE); - setMode(MODE_RX_ON); txfifoFlush = true; } } @@ -795,9 +818,7 @@ private void stopOscillator() { status &= ~STATUS_XOSC16M_STABLE; setState(STATE_POWER_DOWN); - if (DEBUG) System.out.println("CC2420: Oscillator Off."); - setMode(MODE_POWER_OFF); // Reset state setFIFOP(false); } @@ -814,7 +835,7 @@ cpu.scheduleTimeEventMillis(vregEvent, 0.1); if (DEBUG) System.out.println(getName() + ": Scheduling vregEvent at: cyc = " + cpu.cycles + " target: " + vregEvent.getTime() + " current: " + cpu.getTime()); - }else{ + } else { this.on = on; setState(STATE_VREG_OFF); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-10-26 14:47:14
|
Revision: 371 http://mspsim.svn.sourceforge.net/mspsim/?rev=371&view=rev Author: joxe Date: 2008-10-26 14:47:05 +0000 (Sun, 26 Oct 2008) Log Message: ----------- fixed bug when listener of CC2420 was not available Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java mspsim/se/sics/mspsim/platform/sky/SkyNode.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-26 11:57:22 UTC (rev 370) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-26 14:47:05 UTC (rev 371) @@ -755,8 +755,9 @@ setState(STATE_TX_FRAME); } else { if (listener != null) { - listener.receivedByte(SHR[shrPos++]); + listener.receivedByte(SHR[shrPos]); } + shrPos++; cpu.scheduleTimeEventMillis(shrEvent, SYMBOL_PERIOD * 2); } } @@ -764,8 +765,9 @@ private void txNext() { if(txfifoPos <= memory[RAM_TXFIFO]) { if (listener != null) { - listener.receivedByte((byte)(memory[RAM_TXFIFO + txfifoPos++] & 0xFF)); + listener.receivedByte((byte)(memory[RAM_TXFIFO + txfifoPos] & 0xFF)); } + txfifoPos++; // Two symbol periods to send a byte... long time = cpu.scheduleTimeEventMillis(sendEvent, SYMBOL_PERIOD * 2); // System.out.println("Scheduling 2 SYMB at: " + time + " getTime(now): " + cpu.getTime()); Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-10-26 11:57:22 UTC (rev 370) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-10-26 14:47:05 UTC (rev 371) @@ -90,7 +90,7 @@ flash.dataReceived(source, data); /* if nothing selected, just write back a random byte to these devs */ if (!radio.getChipSelect() && !flash.getChipSelect()) { - source.byteReceived(0); +// source.byteReceived(0); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-10-26 11:57:28
|
Revision: 370 http://mspsim.svn.sourceforge.net/mspsim/?rev=370&view=rev Author: joxe Date: 2008-10-26 11:57:22 +0000 (Sun, 26 Oct 2008) Log Message: ----------- added argument -stop and fixed autowrite of 0 if no chip-selected on SkyNode Modified Paths: -------------- mspsim/se/sics/mspsim/chip/CC2420.java mspsim/se/sics/mspsim/chip/M25P80.java mspsim/se/sics/mspsim/core/Chip.java mspsim/se/sics/mspsim/platform/GenericNode.java mspsim/se/sics/mspsim/platform/sky/SkyNode.java Modified: mspsim/se/sics/mspsim/chip/CC2420.java =================================================================== --- mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-13 14:43:44 UTC (rev 369) +++ mspsim/se/sics/mspsim/chip/CC2420.java 2008-10-26 11:57:22 UTC (rev 370) @@ -186,16 +186,10 @@ // a flag indicating read/write public static final int FLAG_RAM_READ = 0x20; + public enum SpiState { WAITING, WRITE_REGISTER, READ_REGISTER, RAM_ACCESS, + READ_RXFIFO, WRITE_TXFIFO}; - public static final int WAITING = 0; - public static final int WRITE_REGISTER = 1; - public static final int READ_REGISTER = 2; - public static final int RAM_ACCESS = 3; - - public static final int READ_RXFIFO = 4; - public static final int WRITE_TXFIFO = 5; - - private int state = WAITING; + private SpiState state = SpiState.WAITING; private int pos; private int address; private int shrPos; @@ -463,12 +457,12 @@ switch(state) { case WAITING: if ((data & FLAG_READ) != 0) { - state = READ_REGISTER; + state = SpiState.READ_REGISTER; } else { - state = WRITE_REGISTER; + state = SpiState.WRITE_REGISTER; } if ((data & FLAG_RAM) != 0) { - state = RAM_ACCESS; + state = SpiState.RAM_ACCESS; address = data & 0x7f; } else { // The register address @@ -477,14 +471,14 @@ if (address == REG_RXFIFO) { // check read/write??? // System.out.println("CC2420: Reading RXFIFO!!!"); - state = READ_RXFIFO; + state = SpiState.READ_RXFIFO; } else if (address == REG_TXFIFO) { - state = WRITE_TXFIFO; + state = SpiState.WRITE_TXFIFO; } } if (data < 0x0f) { strobe(data); - state = WAITING; + state = SpiState.WAITING; } pos = 0; // Assuming that the status always is sent back??? @@ -521,7 +515,7 @@ } } /* register written - go back to wating... */ - state = WAITING; + state = SpiState.WAITING; } break; case READ_REGISTER: @@ -534,7 +528,7 @@ System.out.println("CC2420: read from " + Utils.hex8(address) + " = " + registers[address]); } - state = WAITING; + state = SpiState.WAITING; } return; //break; @@ -760,14 +754,18 @@ setSFD(true); setState(STATE_TX_FRAME); } else { - listener.receivedByte(SHR[shrPos++]); + if (listener != null) { + listener.receivedByte(SHR[shrPos++]); + } cpu.scheduleTimeEventMillis(shrEvent, SYMBOL_PERIOD * 2); } } private void txNext() { if(txfifoPos <= memory[RAM_TXFIFO]) { - listener.receivedByte((byte)(memory[RAM_TXFIFO + txfifoPos++] & 0xFF)); + if (listener != null) { + listener.receivedByte((byte)(memory[RAM_TXFIFO + txfifoPos++] & 0xFF)); + } // Two symbol periods to send a byte... long time = cpu.scheduleTimeEventMillis(sendEvent, SYMBOL_PERIOD * 2); // System.out.println("Scheduling 2 SYMB at: " + time + " getTime(now): " + cpu.getTime()); @@ -824,14 +822,18 @@ public void setChipSelect(boolean select) { chipSelect = select; if (!chipSelect) { - state = WAITING; + state = SpiState.WAITING; } - //if (DEBUG) { - // System.out.println("CC2420: setting chipSelect: " + chipSelect); - //} + if (DEBUG) { + System.out.println("CC2420: setting chipSelect: " + chipSelect); + } } + public boolean getChipSelect() { + return chipSelect; + } + public void setCCAPort(IOPort port, int pin) { ccaPort = port; ccaPin = pin; Modified: mspsim/se/sics/mspsim/chip/M25P80.java =================================================================== --- mspsim/se/sics/mspsim/chip/M25P80.java 2008-10-13 14:43:44 UTC (rev 369) +++ mspsim/se/sics/mspsim/chip/M25P80.java 2008-10-26 11:57:22 UTC (rev 370) @@ -294,6 +294,10 @@ } } + public boolean getChipSelect() { + return chipSelect; + } + public void portWrite(IOPort source, int data) { // Chip select = active low... if (chipSelect && (data & CHIP_SELECT) != 0) { Modified: mspsim/se/sics/mspsim/core/Chip.java =================================================================== --- mspsim/se/sics/mspsim/core/Chip.java 2008-10-13 14:43:44 UTC (rev 369) +++ mspsim/se/sics/mspsim/core/Chip.java 2008-10-26 11:57:22 UTC (rev 370) @@ -103,6 +103,11 @@ public abstract String getName(); public abstract int getModeMax(); + + /* By default the cs is set high */ + public boolean getChipSelect() { + return true; + } public String chipinfo() { return "* no info"; Modified: mspsim/se/sics/mspsim/platform/GenericNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/GenericNode.java 2008-10-13 14:43:44 UTC (rev 369) +++ mspsim/se/sics/mspsim/platform/GenericNode.java 2008-10-26 11:57:22 UTC (rev 370) @@ -94,8 +94,6 @@ } firmwareFile = args[0]; - setup(config); - int[] memory = cpu.getMemory(); if (args[0].endsWith("ihex")) { // IHEX Reading @@ -109,7 +107,10 @@ cpu.getDisAsm().setMap(map); registry.registerComponent("mapTable", map); } + + setup(config); + if (!config.getPropertyAsBoolean("nogui", false)) { // Setup control and other UI components ControlUI control = new ControlUI(registry); Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-10-13 14:43:44 UTC (rev 369) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-10-26 11:57:22 UTC (rev 370) @@ -88,6 +88,10 @@ public void dataReceived(USART source, int data) { radio.dataReceived(source, data); flash.dataReceived(source, data); + /* if nothing selected, just write back a random byte to these devs */ + if (!radio.getChipSelect() && !flash.getChipSelect()) { + source.byteReceived(0); + } } @Override @@ -198,7 +202,9 @@ config.setProperty("nogui", "false"); } node.setupArgs(config); - node.start(); + if (config.getProperty("stop") == null) { + node.start(); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-10-13 14:43:55
|
Revision: 369 http://mspsim.svn.sourceforge.net/mspsim/?rev=369&view=rev Author: nifi Date: 2008-10-13 14:43:44 +0000 (Mon, 13 Oct 2008) Log Message: ----------- Command handler for stream input Added Paths: ----------- mspsim/se/sics/mspsim/cli/StreamCommandHandler.java Added: mspsim/se/sics/mspsim/cli/StreamCommandHandler.java =================================================================== --- mspsim/se/sics/mspsim/cli/StreamCommandHandler.java (rev 0) +++ mspsim/se/sics/mspsim/cli/StreamCommandHandler.java 2008-10-13 14:43:44 UTC (rev 369) @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2008, Swedish Institute of Computer Science. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id$ + * + * ----------------------------------------------------------------- + * + * StreamCommandHandler + * + * Authors : Joakim Eriksson, Niclas Finne + * Created : 13 okt 2008 + * Updated : $Date$ + * $Revision$ + */ + +package se.sics.mspsim.cli; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.InterruptedIOException; +import java.io.PrintStream; + +/** + * + */ +public class StreamCommandHandler extends CommandHandler implements Runnable { + + private BufferedReader inReader; + private boolean workaround = false; + private boolean exit; + + public StreamCommandHandler(InputStream in, PrintStream out, PrintStream err) { + super(out, err); + this.exit = false; + this.inReader = new BufferedReader(new InputStreamReader(in)); + registerCommand("workaround", new BasicCommand("activate workaround for Java console input bug", "") { + public int executeCommand(CommandContext context) { + workaround = true; + return 0; + } + }); + } + + public void setWorkaround(boolean w) { + workaround = w; + } + + public void start() { + super.start(); + new Thread(this, "cmd").start(); + } + + private String readLine(BufferedReader inReader2) throws IOException { + if (workaround) { + StringBuilder str = new StringBuilder(); + while(true) { + if (inReader2.ready()) { + int c = inReader2.read(); + if (c == '\n') { + return str.toString(); + } + if (c != '\r') { + str.append((char)c); + } + } else { + try { + Thread.sleep(500); + } catch (InterruptedException e) { + throw new InterruptedIOException(); + } + } + } + } else { + return inReader2.readLine(); + } + } + + public void run() { + String lastLine = null; + while(!exit) { + try { + out.print(">"); + out.flush(); + String line = readLine(inReader);//.readLine(); + // Simple execution of last called command line when not running from terminal with history support + if (((char) 27 + "[A").equals(line)) { + line = lastLine; + } + if (line != null && line.length() > 0) { + lastLine = line; + lineRead(line); + } + } catch (IOException e) { + e.printStackTrace(err); + err.println("Command line tool exiting..."); + exit = true; + } + } + } + +} Property changes on: mspsim/se/sics/mspsim/cli/StreamCommandHandler.java ___________________________________________________________________ Added: svn:keywords + Rev Date Id Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-10-13 14:28:19
|
Revision: 368 http://mspsim.svn.sourceforge.net/mspsim/?rev=368&view=rev Author: nifi Date: 2008-10-13 14:28:14 +0000 (Mon, 13 Oct 2008) Log Message: ----------- fixed to handle late set of map table Modified Paths: -------------- mspsim/se/sics/mspsim/cli/CommandHandler.java Modified: mspsim/se/sics/mspsim/cli/CommandHandler.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-10-13 14:00:14 UTC (rev 367) +++ mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-10-13 14:28:14 UTC (rev 368) @@ -28,6 +28,13 @@ registerCommands(); } + private MapTable getMapTable() { + if (mapTable == null && registry != null) { + mapTable = (MapTable) registry.getComponent(MapTable.class); + } + return mapTable; + } + // Add it to the command table (overwriting anything there) public void registerCommand(String cmd, Command command) { commands.put(cmd, command); @@ -60,7 +67,7 @@ if (i == 0 && cmd instanceof AsyncCommand) { pid = ++pidCounter; } - commands[i] = new CommandContext(this, mapTable, commandLine, args, pid, cmd); + commands[i] = new CommandContext(this, getMapTable(), commandLine, args, pid, cmd); if (i > 0) { PrintStream po = new PrintStream(new LineOutputStream((LineListener) commands[i].getCommand())); commands[i - 1].setOutput(po, err); @@ -156,8 +163,6 @@ } public void start() { - mapTable = (MapTable) registry.getComponent(MapTable.class); - Object[] commandBundles = registry.getAllComponents(CommandBundle.class); if (commandBundles != null) { for (int i = 0, n = commandBundles.length; i < n; i++) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-10-13 14:00:32
|
Revision: 367 http://mspsim.svn.sourceforge.net/mspsim/?rev=367&view=rev Author: nifi Date: 2008-10-13 14:00:14 +0000 (Mon, 13 Oct 2008) Log Message: ----------- refactoring for better COOJA integration Modified Paths: -------------- mspsim/se/sics/mspsim/cli/CommandHandler.java mspsim/se/sics/mspsim/cli/DebugCommands.java mspsim/se/sics/mspsim/platform/GenericNode.java mspsim/se/sics/mspsim/platform/esb/ESBGui.java mspsim/se/sics/mspsim/platform/esb/ESBNode.java mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java mspsim/se/sics/mspsim/platform/sky/SkyNode.java Modified: mspsim/se/sics/mspsim/cli/CommandHandler.java =================================================================== --- mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-10-12 21:18:04 UTC (rev 366) +++ mspsim/se/sics/mspsim/cli/CommandHandler.java 2008-10-13 14:00:14 UTC (rev 367) @@ -1,41 +1,29 @@ package se.sics.mspsim.cli; - -import java.io.BufferedReader; import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.InterruptedIOException; import java.io.PrintStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Hashtable; -import java.util.Map; - import se.sics.mspsim.util.ActiveComponent; import se.sics.mspsim.util.ComponentRegistry; import se.sics.mspsim.util.MapTable; -public class CommandHandler implements ActiveComponent, Runnable { +public class CommandHandler implements ActiveComponent, LineListener { private String scriptDirectory = "scripts"; private Hashtable<String, Command> commands = new Hashtable<String, Command>(); - private boolean exit; - private boolean workaround = false; - private ArrayList<CommandContext[]> currentAsyncCommands = new ArrayList<CommandContext[]>(); - private BufferedReader inReader; - private PrintStream out; - private PrintStream err; + protected final PrintStream out; + protected final PrintStream err; private MapTable mapTable; private ComponentRegistry registry; + private ArrayList<CommandContext[]> currentAsyncCommands = new ArrayList<CommandContext[]>(); private int pidCounter = 0; - public CommandHandler() { - exit = false; - inReader = new BufferedReader(new InputStreamReader(System.in)); - out = System.out; - err = System.err; + public CommandHandler(PrintStream out, PrintStream err) { + this.out = out; + this.err = err; registerCommands(); } @@ -45,55 +33,6 @@ commands.put(cmd, command); } - - private String readLine(BufferedReader inReader2) throws IOException { - if (workaround) { - StringBuilder str = new StringBuilder(); - while(true) { - if (inReader2.ready()) { - int c = inReader2.read(); - if (c == '\n') { - return str.toString(); - } - if (c != '\r') { - str.append((char)c); - } - } else { - try { - Thread.sleep(500); - } catch (InterruptedException e) { - throw new InterruptedIOException(); - } - } - } - } else { - return inReader2.readLine(); - } - } - - public void run() { - String lastLine = null; - while(!exit) { - try { - out.print(">"); - out.flush(); - String line = readLine(inReader);//.readLine(); - // Simple execution of last called command line when not running from terminal with history support - if (((char) 27 + "[A").equals(line)) { - line = lastLine; - } - if (line != null && line.length() > 0) { - lastLine = line; - executeCommand(line, null); - } - } catch (IOException e) { - e.printStackTrace(err); - err.println("Command line tool exiting..."); - exit = true; - } - } - } - public int executeCommand(String commandLine, CommandContext context) { String[][] parts; PrintStream out = context == null ? this.out : context.out; @@ -216,10 +155,6 @@ this.registry = registry; } - public void setWorkaround(boolean w) { - workaround = w; - } - public void start() { mapTable = (MapTable) registry.getComponent(MapTable.class); @@ -229,7 +164,6 @@ ((CommandBundle) commandBundles[i]).setupCommands(registry, this); } } - new Thread(this, "cmd").start(); } private void registerCommands() { @@ -288,12 +222,6 @@ return 1; } }); - registerCommand("workaround", new BasicCommand("activate workaround for Java console input bug", "") { - public int executeCommand(CommandContext context) { - workaround = true; - return 0; - } - }); registerCommand("ps", new BasicCommand("list current executing commands", "") { public int executeCommand(CommandContext context) { @@ -348,4 +276,10 @@ } return false; } + + @Override + public void lineRead(String line) { + executeCommand(line, null); + } + } Modified: mspsim/se/sics/mspsim/cli/DebugCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-10-12 21:18:04 UTC (rev 366) +++ mspsim/se/sics/mspsim/cli/DebugCommands.java 2008-10-13 14:00:14 UTC (rev 367) @@ -323,7 +323,7 @@ public int executeCommand(final CommandContext context) { Memory xmem = (Memory) DebugCommands.this.registry.getComponent("xmem"); if (xmem == null) { - context.err.print("No xmem component registered"); + context.err.println("No xmem component registered"); return 0; } int start = context.getArgumentAsAddress(0); @@ -359,7 +359,7 @@ public int executeCommand(final CommandContext context) { Memory xmem = (Memory) DebugCommands.this.registry.getComponent("xmem"); if (xmem == null) { - context.err.print("No xmem component registered"); + context.err.println("No xmem component registered"); return 0; } int adr = context.getArgumentAsAddress(0); Modified: mspsim/se/sics/mspsim/platform/GenericNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/GenericNode.java 2008-10-12 21:18:04 UTC (rev 366) +++ mspsim/se/sics/mspsim/platform/GenericNode.java 2008-10-13 14:00:14 UTC (rev 367) @@ -37,13 +37,16 @@ */ package se.sics.mspsim.platform; - +import java.io.ByteArrayOutputStream; +import java.io.DataInputStream; import java.io.IOException; +import java.net.URL; import se.sics.mspsim.cli.CommandHandler; import se.sics.mspsim.cli.DebugCommands; import se.sics.mspsim.cli.MiscCommands; import se.sics.mspsim.cli.ProfilerCommands; +import se.sics.mspsim.cli.StreamCommandHandler; import se.sics.mspsim.cli.WindowCommands; import se.sics.mspsim.core.Chip; import se.sics.mspsim.core.MSP430; @@ -68,53 +71,45 @@ protected String firmwareFile = null; protected ELF elf; protected OperatingModeStatistics stats; - + + public ComponentRegistry getRegistry() { + return registry; + } + + public MSP430 getCPU() { + return cpu; + } + public abstract void setupNode(); - - public void setup(ArgumentManager config) throws IOException { + + public void setCommandHandler(CommandHandler handler) { + registry.registerComponent("commandHandler", handler); + } + + public void setupArgs(ArgumentManager config) throws IOException { String[] args = config.getArguments(); if (args.length == 0) { System.out.println("Usage: " + getClass().getName() + " <firmware>"); System.exit(1); } + firmwareFile = args[0]; - this.config = config; + setup(config); - CommandHandler ch = new CommandHandler(); - stats = new OperatingModeStatistics(cpu); - - registry.registerComponent("cpu", cpu); - registry.registerComponent("commandHandler", ch); - registry.registerComponent("debugcmd", new DebugCommands()); - registry.registerComponent("misccmd", new MiscCommands()); - registry.registerComponent("statcmd", new StatCommands(cpu, stats)); - registry.registerComponent("wincmd", new WindowCommands()); - registry.registerComponent("profilecmd", new ProfilerCommands()); - registry.registerComponent("node", this); - registry.registerComponent("config", config); - - // Monitor execution - cpu.setMonitorExec(true); - //cpu.setDebug(true); int[] memory = cpu.getMemory(); - if (args[0].endsWith("ihex")) { // IHEX Reading IHexReader reader = new IHexReader(); - reader.readFile(memory, firmwareFile = args[0]); + reader.readFile(memory, firmwareFile); } else { - loadFirmware(args[0], memory); + loadFirmware(firmwareFile, memory); } - - cpu.reset(); - setupNode(); - if (args.length > 1) { MapTable map = new MapTable(args[1]); cpu.getDisAsm().setMap(map); registry.registerComponent("mapTable", map); } - + if (!config.getPropertyAsBoolean("nogui", false)) { // Setup control and other UI components ControlUI control = new ControlUI(registry); @@ -123,12 +118,39 @@ control.setSourceViewer(sourceViewer); } - registry.start(); - System.out.println("-----------------------------------------------"); System.out.println("MSPSim " + MSP430Constants.VERSION + " starting firmware: " + firmwareFile); System.out.println("-----------------------------------------------"); } + + public void setup(ConfigManager config) throws IOException { + this.config = config; + registry.registerComponent("cpu", cpu); + registry.registerComponent("node", this); + registry.registerComponent("config", config); + + CommandHandler ch = (CommandHandler) registry.getComponent("commandHandler"); + if (ch == null) { + ch = new StreamCommandHandler(System.in, System.out, System.err); + registry.registerComponent("commandHandler", ch); + } + stats = new OperatingModeStatistics(cpu); + registry.registerComponent("debugcmd", new DebugCommands()); + registry.registerComponent("misccmd", new MiscCommands()); + registry.registerComponent("statcmd", new StatCommands(cpu, stats)); + registry.registerComponent("wincmd", new WindowCommands()); + registry.registerComponent("profilecmd", new ProfilerCommands()); + + // Monitor execution + cpu.setMonitorExec(true); + //cpu.setDebug(true); + + setupNode(); + + registry.start(); + + cpu.reset(); + } public void run() { @@ -153,23 +175,42 @@ cpu.step(); } } - - public void loadFirmware(String name, int[] memory) throws IOException { + + public ELF loadFirmware(URL url, int[] memory) throws IOException { + DataInputStream inputStream = new DataInputStream(url.openStream()); + ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); + byte[] firmwareData = new byte[2048]; + int read; + while ((read = inputStream.read(firmwareData)) != -1) { + byteStream.write(firmwareData, 0, read); + } + inputStream.close(); + ELF elf = new ELF(byteStream.toByteArray()); + elf.readAll(); + return loadFirmware(elf, memory); + } + + public ELF loadFirmware(String name, int[] memory) throws IOException { + return loadFirmware(ELF.readELF(firmwareFile = name), memory); + } + + public ELF loadFirmware(ELF elf, int[] memory) { stop(); - elf = ELF.readELF(firmwareFile = name); + this.elf = elf; elf.loadPrograms(memory); MapTable map = elf.getMap(); cpu.getDisAsm().setMap(map); cpu.setMap(map); registry.registerComponent("elf", elf); registry.registerComponent("mapTable", map); + return elf; } - + // A step that will break out of breakpoints! public void step(int nr) { if (!cpu.isRunning()) { cpu.stepInstructions(nr); } } - + } Modified: mspsim/se/sics/mspsim/platform/esb/ESBGui.java =================================================================== --- mspsim/se/sics/mspsim/platform/esb/ESBGui.java 2008-10-12 21:18:04 UTC (rev 366) +++ mspsim/se/sics/mspsim/platform/esb/ESBGui.java 2008-10-13 14:00:14 UTC (rev 367) @@ -160,7 +160,9 @@ byte[] data = new byte[4]; public int nextData() { - inDataLine.read(data, 0, 4); + if (inDataLine != null) { + inDataLine.read(data, 0, 4); + } //System.out.println("sampled: " + ((data[1] << 8) + data[0])); return (((data[1] & 0xff) << 8) | data[0] & 0xff) >> 4; } Modified: mspsim/se/sics/mspsim/platform/esb/ESBNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2008-10-12 21:18:04 UTC (rev 366) +++ mspsim/se/sics/mspsim/platform/esb/ESBNode.java 2008-10-13 14:00:14 UTC (rev 367) @@ -104,12 +104,6 @@ cpu.setDebug(debug); } - - public MSP430 getCPU() { - return cpu; - } - - public void portWrite(IOPort source, int data) { // System.out.println("ESB: Writing to port: " + data); if (source == port2) { @@ -171,7 +165,7 @@ stats.addMonitor(radio); stats.addMonitor(cpu); - if (!config.getPropertyAsBoolean("nogui", false)) { + if (!config.getPropertyAsBoolean("nogui", true)) { gui = new ESBGui(this); // A HACK for some "graphs"!!! @@ -195,7 +189,10 @@ ESBNode node = new ESBNode(); ArgumentManager config = new ArgumentManager(); config.handleArguments(args); - node.setup(config); + if (config.getProperty("nogui") == null) { + config.setProperty("nogui", "false"); + } + node.setupArgs(config); node.start(); } Modified: mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java 2008-10-12 21:18:04 UTC (rev 366) +++ mspsim/se/sics/mspsim/platform/sky/MoteIVNode.java 2008-10-13 14:00:14 UTC (rev 367) @@ -4,7 +4,6 @@ import se.sics.mspsim.chip.SHT11; import se.sics.mspsim.core.IOPort; import se.sics.mspsim.core.IOUnit; -import se.sics.mspsim.core.MSP430; import se.sics.mspsim.core.PortListener; import se.sics.mspsim.core.USARTListener; import se.sics.mspsim.platform.GenericNode; @@ -63,10 +62,6 @@ cpu.setDebug(debug); } - public MSP430 getCPU() { - return cpu; - } - public void setButton(boolean hi) { port2.setPinState(BUTTON_PIN, hi ? IOPort.PIN_HI : IOPort.PIN_LOW); } @@ -79,9 +74,9 @@ return elf; } - public void setupNodePorts(boolean loadFlash) { + public void setupNodePorts() { sht11 = new SHT11(cpu); - + IOUnit unit = cpu.getIOUnit("Port 5"); if (unit instanceof IOPort) { port5 = (IOPort) unit; Modified: mspsim/se/sics/mspsim/platform/sky/SkyNode.java =================================================================== --- mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-10-12 21:18:04 UTC (rev 366) +++ mspsim/se/sics/mspsim/platform/sky/SkyNode.java 2008-10-13 14:00:14 UTC (rev 367) @@ -41,7 +41,6 @@ package se.sics.mspsim.platform.sky; import java.io.IOException; - import se.sics.mspsim.chip.CC2420; import se.sics.mspsim.chip.FileM25P80; import se.sics.mspsim.chip.M25P80; @@ -55,7 +54,6 @@ import se.sics.mspsim.util.ArgumentManager; import se.sics.mspsim.util.NetworkConnection; import se.sics.mspsim.util.OperatingModeStatistics; -import se.sics.mspsim.util.Utils; /** * Emulation of Sky Mote @@ -83,9 +81,9 @@ public void setFlash(M25P80 flash) { this.flash = flash; + registry.registerComponent("xmem", flash); } - // USART Listener public void dataReceived(USART source, int data) { radio.dataReceived(source, data); @@ -101,8 +99,8 @@ return "Tmote Sky"; } - public void setupNodePorts(boolean loadFlash) { - super.setupNodePorts(loadFlash); + public void setupNodePorts() { + super.setupNodePorts(); IOUnit usart0 = cpu.getIOUnit("USART 0"); if (usart0 instanceof USART) { @@ -110,12 +108,12 @@ radio.setCCAPort(port1, CC2420_CCA); radio.setFIFOPPort(port1, CC2420_FIFOP); radio.setFIFOPort(port1, CC2420_FIFO); - if (loadFlash) { - flash = new FileM25P80(cpu, flashFile); + if (flashFile != null) { + setFlash(new FileM25P80(cpu, flashFile)); } ((USART) usart0).setUSARTListener(this); port4 = (IOPort) cpu.getIOUnit("Port 4"); - if (port4 != null && port4 instanceof IOPort) { + if (port4 != null) { port4.setPortListener(this); radio.setSFDPort(port4, CC2420_SFD); } @@ -128,44 +126,49 @@ String fileName = config.getProperty("flashfile"); if (fileName == null) { fileName = firmwareFile; - int ix = fileName.lastIndexOf('.'); - if (ix > 0) { - fileName = fileName.substring(0, ix); + if (fileName != null) { + int ix = fileName.lastIndexOf('.'); + if (ix > 0) { + fileName = fileName.substring(0, ix); + } + fileName = fileName + ".flash"; } - fileName = fileName + ".flash"; } - System.out.println("Using flash file: " + fileName); + System.out.println("Using flash file: " + (fileName == null ? "no file" : fileName)); this.flashFile = fileName; - setupNodePorts(true); + setupNodePorts(); stats.addMonitor(this); stats.addMonitor(radio); stats.addMonitor(cpu); - network = new NetworkConnection(); - final RadioWrapper radioWrapper = new RadioWrapper(radio); - radioWrapper.setPacketListener(new PacketListener() { - public void transmissionStarted() { - } - public void transmissionEnded(byte[] receivedData) { -// System.out.println("**** Sending data len = " + receivedData.length); -// for (int i = 0; i < receivedData.length; i++) { -// System.out.println("Byte: " + Utils.hex8(receivedData[i])); -// } - network.dataSent(receivedData); - } - }); - - network.addPacketListener(new PacketListener() { - public void transmissionStarted() { - } - public void transmissionEnded(byte[] receivedData) { -// System.out.println("**** Receiveing data = " + receivedData.length); - radioWrapper.packetReceived(receivedData); - } - }); + if (config.getPropertyAsBoolean("enableNetwork", false)) { + network = new NetworkConnection(); + final RadioWrapper radioWrapper = new RadioWrapper(radio); + radioWrapper.setPacketListener(new PacketListener() { + public void transmissionStarted() { + } + public void transmissionEnded(byte[] receivedData) { + // System.out.println("**** Sending data len = " + receivedData.length); + // for (int i = 0; i < receivedData.length; i++) { + // System.out.println("Byte: " + Utils.hex8(receivedData[i])); + // } + network.dataSent(receivedData); + } + }); + + network.addPacketListener(new PacketListener() { + public void transmissionStarted() { + } + public void transmissionEnded(byte[] receivedData) { + // System.out.println("**** Receiving data = " + receivedData.length); + radioWrapper.packetReceived(receivedData); + } + }); + } + // UART0 TXreg = 0x77? // cpu.setBreakPoint(0x77, new CPUMonitor() { // public void cpuAction(int type, int adr, int data) { @@ -174,7 +177,7 @@ // } // }); - if (!config.getPropertyAsBoolean("nogui", false)) { + if (!config.getPropertyAsBoolean("nogui", true)) { gui = new SkyGui(this); // A HACK for some "graphs"!!! @@ -185,15 +188,16 @@ dataChart.addDataSource(dss, "Transmit", stats.getDataSource("CC2420", CC2420.MODE_TXRX_ON)); dataChart.addDataSource(dss, "CPU", stats.getDataSource("MSP430 Core", MSP430.MODE_ACTIVE)); } - registry.registerComponent("xmem", flash); } - public static void main(String[] args) throws IOException { SkyNode node = new SkyNode(); ArgumentManager config = new ArgumentManager(); config.handleArguments(args); - node.setup(config); + if (config.getProperty("nogui") == null) { + config.setProperty("nogui", "false"); + } + node.setupArgs(config); node.start(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-10-12 21:18:16
|
Revision: 366 http://mspsim.svn.sourceforge.net/mspsim/?rev=366&view=rev Author: nifi Date: 2008-10-12 21:18:04 +0000 (Sun, 12 Oct 2008) Log Message: ----------- only call profiler if such is found Modified Paths: -------------- mspsim/se/sics/mspsim/cli/ProfilerCommands.java Modified: mspsim/se/sics/mspsim/cli/ProfilerCommands.java =================================================================== --- mspsim/se/sics/mspsim/cli/ProfilerCommands.java 2008-10-12 21:12:06 UTC (rev 365) +++ mspsim/se/sics/mspsim/cli/ProfilerCommands.java 2008-10-12 21:18:04 UTC (rev 366) @@ -94,7 +94,7 @@ }); - ch.registerCommand("printcalls", new BasicAsyncCommand("print functioncalls", "") { + ch.registerCommand("printcalls", new BasicAsyncCommand("print function calls", "") { @Override public int executeCommand(CommandContext context) { Profiler profiler = cpu.getProfiler(); @@ -108,10 +108,9 @@ @Override public void stopCommand(CommandContext context) { Profiler profiler = cpu.getProfiler(); - if (profiler == null) { - context.err.println("No profiler found."); + if (profiler != null) { + profiler.setLogger(null); } - profiler.setLogger(null); } }); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ni...@us...> - 2008-10-12 21:12:18
|
Revision: 365 http://mspsim.svn.sourceforge.net/mspsim/?rev=365&view=rev Author: nifi Date: 2008-10-12 21:12:06 +0000 (Sun, 12 Oct 2008) Log Message: ----------- removed some debug printout Modified Paths: -------------- mspsim/se/sics/mspsim/chip/SHT11.java Modified: mspsim/se/sics/mspsim/chip/SHT11.java =================================================================== --- mspsim/se/sics/mspsim/chip/SHT11.java 2008-10-12 20:53:54 UTC (rev 364) +++ mspsim/se/sics/mspsim/chip/SHT11.java 2008-10-12 21:12:06 UTC (rev 365) @@ -129,7 +129,7 @@ crc = crc8Add(crc, readData); crc = crc8Add(crc, output[0]); crc = crc8Add(crc, output[1]); - System.out.println("CRC: " + crc + " rcrc: " + rev8bits(crc)); + if (DEBUG) System.out.println("CRC: " + crc + " rcrc: " + rev8bits(crc)); output[2] = rev8bits(crc); /* finished measuring - signal with LOW! */ @@ -178,7 +178,7 @@ readData = (readData << 1) | (dataHi ? 1 : 0); bitCnt++; if (bitCnt == 8) { - System.out.println("SHT11: read: " + Utils.hex8(readData)); + if (DEBUG) System.out.println("SHT11: read: " + Utils.hex8(readData)); bitCnt = 0; state = ACK_CMD; sdataPort.setPinState(sdataPin, IOPort.PIN_LOW); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-10-12 20:54:03
|
Revision: 364 http://mspsim.svn.sourceforge.net/mspsim/?rev=364&view=rev Author: joxe Date: 2008-10-12 20:53:54 +0000 (Sun, 12 Oct 2008) Log Message: ----------- removed some debug printout and updated CHANGELOG Modified Paths: -------------- mspsim/CHANGE_LOG.txt mspsim/se/sics/mspsim/chip/SHT11.java Modified: mspsim/CHANGE_LOG.txt =================================================================== --- mspsim/CHANGE_LOG.txt 2008-10-12 20:49:52 UTC (rev 363) +++ mspsim/CHANGE_LOG.txt 2008-10-12 20:53:54 UTC (rev 364) @@ -12,8 +12,8 @@ - improved correctness of timer when reconfiguring CPU clock speed (MCLK) - improved interrupt handling in MSP430 core - added CLI command printcalls that prints all function calls +- fixed buffering of serial input in GUI to avoid freezing AWT. - 0.93 Changes: - removed tick based component support from MSP430 core Modified: mspsim/se/sics/mspsim/chip/SHT11.java =================================================================== --- mspsim/se/sics/mspsim/chip/SHT11.java 2008-10-12 20:49:52 UTC (rev 363) +++ mspsim/se/sics/mspsim/chip/SHT11.java 2008-10-12 20:53:54 UTC (rev 364) @@ -206,14 +206,14 @@ if (bitCnt == 8) { // All bits are written! state = ACK_WRITE; - System.out.println("Wrote byte: " + output[writePos]); + if (DEBUG) System.out.println("Wrote byte: " + output[writePos]); writePos++; } } break; case ACK_WRITE: if (c == 'C' && dataHi) { - System.out.println("*** NO ACK???"); + if (DEBUG) System.out.println("*** NO ACK???"); reset(0); } break; @@ -233,7 +233,7 @@ break; case ACK_WRITE: if (c == 'D') { // if D goes back high - then we are done here!!! - System.out.println("ACK for byte complete..."); + if (DEBUG) System.out.println("ACK for byte complete..."); if (writePos < writeLen) { state = WRITE_BYTE; writeData = output[writePos]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jo...@us...> - 2008-10-12 20:49:59
|
Revision: 363 http://mspsim.svn.sourceforge.net/mspsim/?rev=363&view=rev Author: joxe Date: 2008-10-12 20:49:52 +0000 (Sun, 12 Oct 2008) Log Message: ----------- fixed buffering of serial input in the GUI Modified Paths: -------------- mspsim/CHANGE_LOG.txt mspsim/se/sics/mspsim/ui/SerialMon.java Modified: mspsim/CHANGE_LOG.txt =================================================================== --- mspsim/CHANGE_LOG.txt 2008-10-12 16:16:45 UTC (rev 362) +++ mspsim/CHANGE_LOG.txt 2008-10-12 20:49:52 UTC (rev 363) @@ -11,6 +11,7 @@ - added SFD capture interrupt support for CC2420 - improved correctness of timer when reconfiguring CPU clock speed (MCLK) - improved interrupt handling in MSP430 core +- added CLI command printcalls that prints all function calls 0.93 Modified: mspsim/se/sics/mspsim/ui/SerialMon.java =================================================================== --- mspsim/se/sics/mspsim/ui/SerialMon.java 2008-10-12 16:16:45 UTC (rev 362) +++ mspsim/se/sics/mspsim/ui/SerialMon.java 2008-10-12 20:49:52 UTC (rev 363) @@ -42,8 +42,12 @@ package se.sics.mspsim.ui; import java.awt.BorderLayout; import java.awt.Color; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; +import java.util.ArrayList; + import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JScrollPane; @@ -63,9 +67,36 @@ private JLabel statusLabel; private String text = "*** Serial mon for MSPsim ***\n"; + private final static int BUFFER_SIZE = 20; + private byte[] buffer = new byte[BUFFER_SIZE]; + private int wPos = 0; + private int rPos = 0; + private int bsize = 0; + + private ActionListener bufferTimer = new ActionListener() { + public void actionPerformed(ActionEvent evt) { + if (bsize > 0) { + if (usart.isReceiveFlagCleared()) { + usart.byteReceived(buffer[rPos]); + rPos = (rPos + 1) % BUFFER_SIZE; + if (bsize == 20) { + statusLabel.setText(keyBuffer.toString()); + } + bsize--; + } + } else { + timer.stop(); + } + } + }; + + private javax.swing.Timer timer = new javax.swing.Timer(100, bufferTimer); private int lines = 1; private boolean isUpdatePending = false; private StringBuilder keyBuffer = new StringBuilder(); + + + public SerialMon(USART usart, String name) { this.name = name; @@ -136,21 +167,19 @@ public void keyTyped(KeyEvent key) { char c = key.getKeyChar(); - if(!usart.isReceiveFlagCleared()) { - try { - // Wait for at most 2 seconds before giving up - for (int i = 0, n = 20; !usart.isReceiveFlagCleared() && i < n; i++) { - Thread.sleep(100); - } - } catch (InterruptedException e) { - // Ignore + // Send it to the usart if possible! + if (usart.isReceiveFlagCleared() && bsize == 0) { + usart.byteReceived(c & 0xff); + } else if (bsize < BUFFER_SIZE){ + buffer[wPos] = (byte) (c & 0xff); + wPos = (wPos + 1) % BUFFER_SIZE; + bsize++; + if (!timer.isRunning()) { + timer.start(); } } - // Send it to the usart if possible! - if (usart.isReceiveFlagCleared()) { - usart.byteReceived(c & 0xff); - + if (bsize < BUFFER_SIZE) { // Visualize the input if (c == '\n') { statusLabel.setText(PREFIX); @@ -162,6 +191,7 @@ } } else { statusLabel.getToolkit().beep(); + statusLabel.setText("*** input buffer full ***"); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |