SimulatingSlip
From JopWiki
Contents |
[edit] HOWTO simulate a network connection with jsim
[edit] Purpose
to simulate the network stack or network applications on jop without real hardware.
architecture:
######## ######### ########### ######### ###### ############## # # # # # # # # # # # # # jsim #=# vcom1 #=# com0com #=# vcom2 #=# os #=# networkapp # # # # # # # # # # # # # ######## ######### ########### ######### ###### ##############
[edit] Requirements
- jdk
- a jop cvs checkout
- RXTX 2.1+
for windows: com0com
others: i tried it with windows(2k) only. you should be able to get it working on unix using socat instead of com0com though.
an even more plattform independent way would be to use a javax.comm implementation with two physical serial ports and nullmodem cable (as done by martin schöberl).
[edit] Steps
- install the jdk and checkout jop
- in the jop Makefile change P1, P2, P3 (variables specifying directory, package, main class) to:
P1=common P2=ejip/examples P3=MainSlipUart2
- second change in the Makefile: in the target section jsim: there is a missing library and you can specify the "IO simulation class" that maps memory accesses inside jsim to events you can use outside the simulator. the (current) default "IOSimMin" is correct though.
- the correct cli should read:
java $(DEBUG_JOPSIM) -cp java/tools/dist/lib/jop-tools.jar\;java/lib/RXTXcomm.jar\; -Dlog="false" -Dioclass="IOSimMin" \ com.jopdesign.tools.JopSim java/target/dist/bin/$(JOPBIN)
- install rxtx
- copy RXTXcomm.jar into java/lib/ of the jop directory.
- copy rxtxSerial.dll into the root jop dir.
- install com0com
- its important that the virtual com ports are named COM?? where ?? is a number (below 16?). otherwise RXTX will not find the ports.
- setup a slip connection in windows
- clickyclicky bla... [1]
- the default ip for jop is 192.168.1.2 (defined in MainSlipUart2 or whatever calls Slip.init(..)), so the pc should get 192.168.1.1 if possible.
- change IOSimMin.java (in \java\tools\src\com\jopdesign\tools)
- add imports for rxtx stuff:
import gnu.io.*; import java.io.*; import java.util.Enumeration;
- remove comments from the fields (portName etc)
- remove comments from openSerialPort() and all switch/if statements regarding IO_UART2 and IO_STATUS2(?)
- add a argumentless constructor, that opens one of the virtual ports (i.e. "vcom1")
public IOSimMin(){
portName = System.getProperty("port", "COM3");
openSerialPort();
}
[edit] compiling and running
you should be able to recompile the simulator (which is necessary whenever you change IOSimMin or JopSim, make wont recompile them itself, when running the simulator!)
make tools
and run the jop appilcation defined in the makefile with the P? variables:
make jsim
after the simulator has started you can "dial" to the simulator and ping it. the output should be something like:
java -cp java/tools/dist/lib/jop-tools.jar\;java/lib/RXTXcomm.jar\; -Dlog="false" -Dioclass="IOSimMin" \
com.jopdesign.tools.JopSim java/target/dist/bin/MainSlipUart2.jop
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
openCOM3
Program: java/target/dist/bin/MainSlipUart2.jop
13111 instruction word (51 KB)
13111 words mem read (51 KB)
JOP start V 0
1 MHz, 1024 KB RAM, 1024 Byte on-chip RAM
*********tCLIENT*****************r60 P800 s60 **r60 P800 s60 **r60 P800 s60 **r60 P800 s60 ********
the *s are from the watchdog, "tCLIENT" is printed, when windows connects, the remaining text are pings.
[edit] further tips
- you can use wireshark to debug network issues just like with normal interfaces.
