yes you can, here is what i did:
2) rename
jamod-1.2-SNAPSHOT.jar to jamod.jar
3) quit processing
4) go to processing's libraries folder
5) create folder jamod
6) create folder library inside jamod
7) copy jamod.jar from 2) to the library folder created under 6)
8) start processing
for testing (you need to run a slave to connect to i believe, but for testing purposes it should give you the feedback in the processing editor console that proves jamod is working), rest is up to you i guess.
- import net.wimpi.modbus.*;
- import net.wimpi.modbus.msg.*;
- import net.wimpi.modbus.io.*;
- import net.wimpi.modbus.net.*;
- import net.wimpi.modbus.util.*;
- void setup() {
- TCPMasterConnection con = null; //the connection
- ModbusTCPTransaction trans = null; //the transaction
- ReadInputDiscretesRequest req = null; //the request
- ReadInputDiscretesResponse res = null; //the response
- /* Variables for storing the parameters */
- InetAddress addr = null; //the slave's address
- int port = Modbus.DEFAULT_PORT;
- int ref = 0; //the reference; offset where to start reading from
- int count = 0; //the number of DI's to read
- int repeat = 1; //a loop for repeating the transaction
- try {
- addr = InetAddress.getByName("localhost");
- port = 10002;
- // (TCP server port from the ChatServer example, run the ChatServer to connect to a random TCP server)
- } catch(UnknownHostException e) {
- println(e);
- }
-
- try {
- con = new TCPMasterConnection(addr);
- con.setPort(port);
- con.connect();
- } catch (Exception e) {
- println(e);
- }
-
- //3. Prepare the request
- req = new ReadInputDiscretesRequest(ref, count);
- //4. Prepare the transaction
- trans = new ModbusTCPTransaction(con);
- trans.setRequest(req);
-
- //5. Execute the transaction repeat times
- int k = 0;
- do {
- try {
- trans.execute();
- res = (ReadInputDiscretesResponse) trans.getResponse();
- System.out.println("Digital Inputs Status=" + res.getDiscretes().toString());
- } catch(Exception e) {
- println(e);
- }
- k++;
- }
- while (k < repeat);
- //6. Close the connection
- con.close();
- println("done");
- }
- void draw() {}
andreas schlegel,
http://www.sojamo.de