Skip to content

Commit

Permalink
fixed license - now for each file separately
Browse files Browse the repository at this point in the history
  • Loading branch information
aploese committed Apr 9, 2024
1 parent 227e872 commit ef22ce5
Show file tree
Hide file tree
Showing 32 changed files with 555 additions and 566 deletions.
5 changes: 5 additions & 0 deletions de.ibapl.onewire4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* OneWire4J - Drivers for the 1-wire protocol https://github.com/aploese/OneWire4J/
* Copyright (C) 2017-2023, Arne Plöse and individual contributors as indicated
* Copyright (C) 2017-2024, Arne Plöse and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
Expand Down Expand Up @@ -88,6 +88,7 @@ public enum State {
* Creates a new instance and initialize the serial port with 9600,8,n,1.
*
* @param serialPortSocket the {@linkplain SerialPortSocket} to use.
* @throws java.io.IOException
*/
public DS2480BAdapter(SerialPortSocket serialPortSocket) throws IOException {
if (!serialPortSocket.isOpen()) {
Expand Down Expand Up @@ -224,12 +225,11 @@ public byte sendByte(byte b, OneWireSpeed speed) throws IOException {
for (int i = 0; i < 8; i++) {
final SingleBitResponse sbr = ((SingleBitRequest) requests[i]).response;
switch (sbr.bitResult) {
case _O_READ_BACK:
break;
case _1_READ_BACK:
case _O_READ_BACK -> {
}
case _1_READ_BACK ->
result |= (byte) (0x01 << i);
break;
default:
default ->
throw new RuntimeException();
}
}
Expand All @@ -247,20 +247,19 @@ public byte sendByteWithPower(byte b, StrongPullupDuration strongPullupDuration,
sbr.dataToSend = (b & 0x01) == 0x01 ? DataToSend.WRITE_1_OR_READ_BIT : DataToSend.WRITE_0_BIT;
b >>= 1;
sbr.speed = speed;
sbr.armPowerDelivery = (i < 7) ? false : true;
sbr.armPowerDelivery = i >= 7;
requests[i + 1] = sbr;
}
sendCommands(requests);
byte result = 0;
for (int i = 0; i < 8; i++) {
final SingleBitResponse sbr = ((SingleBitRequest) requests[i + 1]).response;
switch (sbr.bitResult) {
case _O_READ_BACK:
break;
case _1_READ_BACK:
case _O_READ_BACK -> {
}
case _1_READ_BACK ->
result |= (byte) (0x01 << i);
break;
default:
default ->
throw new RuntimeException();
}
}
Expand All @@ -271,17 +270,17 @@ public byte sendByteWithPower(byte b, StrongPullupDuration strongPullupDuration,
public <R> R sendCommand(OneWireRequest<R> request) throws IOException {
readGarbage();
switch (state) {
case COMMAND:
case COMMAND -> {
if (request instanceof DataRequest) {
setState(State.DATA);
}
break;
case DATA:
}
case DATA -> {
if ((request instanceof CommandRequest) || (request instanceof CommunicationRequest)) {
setState(State.COMMAND);
}
break;
default:
}
default ->
throw new IllegalStateException("Can't hande adapter state: " + state);
}
encoder.encode(request);
Expand All @@ -297,17 +296,17 @@ public void sendCommands(OneWireRequest<?>... requests) throws IOException {
readGarbage();
for (OneWireRequest<?> request : requests) {
switch (state) {
case COMMAND:
case COMMAND -> {
if (request instanceof DataRequest) {
setState(State.DATA);
}
break;
case DATA:
}
case DATA -> {
if ((request instanceof CommandRequest) || (request instanceof CommunicationRequest)) {
setState(State.COMMAND);
}
break;
default:
}
default ->
throw new IllegalStateException("Can't hande adapter state: " + state);
}
encoder.encode(request);
Expand Down Expand Up @@ -383,14 +382,12 @@ private void setState(State state) throws IOException {
return;
}
switch (state) {
case COMMAND:
case COMMAND ->
encoder.put(Encoder.SWITCH_TO_COMMAND_MODE_BYTE);
break;
case DATA:
case DATA ->
encoder.put(Encoder.SWITCH_TO_DATA_MODE_BYTE);
break;
default:
break;
default -> {
}
}
}

Expand Down
Loading

0 comments on commit ef22ce5

Please sign in to comment.