Skip to content

Commit

Permalink
Update jserialcom to 2.10.3 (#139)
Browse files Browse the repository at this point in the history
* Solve ambiguous object Record (java 14)
* Update jSerialComm to 2.10.3, breaking change in readBytes and writeBytes
Co-authored-by: a.soullier <[email protected]>
  • Loading branch information
AmbroiseS authored Oct 21, 2023
1 parent a608351 commit 443ca7c
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<dependency>
<groupId>com.fazecast</groupId>
<artifactId>jSerialComm</artifactId>
<version>2.9.3</version>
<version>2.10.3</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ protected int readByte() throws IOException {
* @param bytesToRead Number of bytes to read
* @throws IOException If the port is invalid or if the number of bytes returned is not equal to that asked for
*/
void readBytes(byte[] buffer, long bytesToRead) throws IOException {
void readBytes(byte[] buffer, int bytesToRead) throws IOException {
if (commPort != null && commPort.isOpen()) {
int cnt = commPort.readBytes(buffer, bytesToRead);
if (cnt != bytesToRead) {
Expand All @@ -432,7 +432,7 @@ void readBytes(byte[] buffer, long bytesToRead) throws IOException {
*
* @throws java.io.IOException if writing to invalid port
*/
final int writeBytes(byte[] buffer, long bytesToWrite) throws IOException {
final int writeBytes(byte[] buffer, int bytesToWrite) throws IOException {
if (commPort != null && commPort.isOpen()) {
return commPort.writeBytes(buffer, bytesToWrite);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.ghgande.j2mod.modbus.msg.ReadFileRecordResponse.RecordResponse;
import com.ghgande.j2mod.modbus.net.AbstractModbusListener;
import com.ghgande.j2mod.modbus.procimg.*;
import com.ghgande.j2mod.modbus.procimg.Record;

import java.io.DataInput;
import java.io.DataOutput;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.ghgande.j2mod.modbus.msg.WriteFileRecordResponse.RecordResponse;
import com.ghgande.j2mod.modbus.net.AbstractModbusListener;
import com.ghgande.j2mod.modbus.procimg.*;
import com.ghgande.j2mod.modbus.procimg.Record;

import java.io.DataInput;
import java.io.DataOutput;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public abstract class AbstractSerialConnection {
* @param bytesToRead Number of bytes to read
* @return number of currently bytes read
*/
public abstract int readBytes(byte[] buffer, long bytesToRead);
public abstract int readBytes(byte[] buffer, int bytesToRead);

/**
* Write a specified number of bytes to the serial port
Expand All @@ -86,7 +86,7 @@ public abstract class AbstractSerialConnection {
* @param bytesToWrite How many bytes to send
* @return number of currently bytes written
*/
public abstract int writeBytes(byte[] buffer, long bytesToWrite);
public abstract int writeBytes(byte[] buffer, int bytesToWrite);

/**
* Bytes available to read
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ public synchronized void setTimeout(int timeout) {
}

@Override
public int readBytes(byte[] buffer, long bytesToRead) {
public int readBytes(byte[] buffer, int bytesToRead) {
return serialPort == null ? 0 : serialPort.readBytes(buffer, bytesToRead);
}

@Override
public int writeBytes(byte[] buffer, long bytesToWrite) {
public int writeBytes(byte[] buffer, int bytesToWrite) {
return serialPort == null ? 0 : serialPort.writeBytes(buffer, bytesToWrite);
}

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/ghgande/j2mod/modbus/cmd/TCPSlaveTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.ghgande.j2mod.modbus.cmd;

import com.ghgande.j2mod.modbus.Modbus;
import com.ghgande.j2mod.modbus.procimg.Record;
import com.ghgande.j2mod.modbus.procimg.*;
import com.ghgande.j2mod.modbus.slave.ModbusSlave;
import com.ghgande.j2mod.modbus.slave.ModbusSlaveFactory;
Expand Down Expand Up @@ -104,8 +105,7 @@ public static void main(String[] args) {
ModbusSlave slave = ModbusSlaveFactory.createTCPSlave(port, 5);
slave.addProcessImage(unit, spi);
slave.open();
}
catch (Exception ex) {
} catch (Exception ex) {
ex.printStackTrace();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.ghgande.j2mod.modbus.Modbus;
import com.ghgande.j2mod.modbus.procimg.*;
import com.ghgande.j2mod.modbus.procimg.Record;
import com.ghgande.j2mod.modbus.slave.ModbusSlave;
import com.ghgande.j2mod.modbus.slave.ModbusSlaveFactory;
import org.slf4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.ghgande.j2mod.modbus.utils;

import com.ghgande.j2mod.modbus.procimg.*;
import com.ghgande.j2mod.modbus.procimg.Record;
import com.ghgande.j2mod.modbus.slave.ModbusSlave;
import com.ghgande.j2mod.modbus.util.Observable;
import com.ghgande.j2mod.modbus.util.Observer;
Expand Down

0 comments on commit 443ca7c

Please sign in to comment.