Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v5
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Set up Java
uses: actions/setup-java@v5
- uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
with:
distribution: 'temurin'
java-version: '8'
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v5
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Set up Java
uses: actions/setup-java@v5
- uses: actions/setup-java@de7274f081f381c8f8158605e0321c36c376e2e6 # v6.0.1
with:
distribution: 'temurin'
java-version: '8'
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/github-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Create GitHub Release
env:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<artifactId>j2mod</artifactId>
<name>j2mod</name>
<url>https://github.com/OpenEMS/j2mod</url>
<version>3.4.0-openems.1</version>
<version>3.4.0-openems.2-SNAPSHOT</version>
<description>A Modbus TCP/UDP/Serial Master and Slave implementation</description>

<packaging>bundle</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ public abstract class ModbusSerialTransport extends AbstractModbusTransport {
/**
* The number of nanoseconds there is in a millisecond
*/
private static final int NS_IN_A_MS = 1_000_000;
private static final double NS_IN_A_MS = 1_000_000.0;

/**
* The number of nanoseconds there is in a second
*/
private static final int NS_IN_A_SEC = 1_000_000_000;
private static final double NS_IN_A_SEC = 1_000_000_000.0;

private static final String CANNOT_READ_FROM_SERIAL_PORT = "Cannot read from serial port";
private static final String COMM_PORT_IS_NOT_VALID_OR_NOT_OPEN = "Comm port is not valid or not open";
Expand Down Expand Up @@ -121,7 +121,7 @@ private void waitForTransmission(long startTime, double transmissionTimeNanos) {
if (transmissionTimeNanos >= NS_IN_A_MS) {
try {
final long adjustedDelay = (long) (transmissionTimeNanos * LONG_DELAY_FUDGE_FACTOR);
final long sleepMillis = adjustedDelay / NS_IN_A_MS;
final long sleepMillis = (long) (adjustedDelay / NS_IN_A_MS);
final int sleepNanos = (int) (adjustedDelay % NS_IN_A_MS);

Thread.sleep(sleepMillis, sleepNanos);
Expand Down Expand Up @@ -637,7 +637,7 @@ void waitBetweenFrames(int transDelayMS, long lastTransactionTimestamp) {
int delay = getInterFrameDelay() / 1000;

// How long since the last message we received
long gapSinceLastMessage = (System.nanoTime() - lastTransactionTimestamp) / NS_IN_A_MS;
long gapSinceLastMessage = (long) ((System.nanoTime() - lastTransactionTimestamp) / NS_IN_A_MS);
if (delay > gapSinceLastMessage) {
long sleepTime = delay - gapSinceLastMessage;

Expand Down
Loading