diff --git a/build.gradle b/build.gradle
index 3998548c..e1e55714 100644
--- a/build.gradle
+++ b/build.gradle
@@ -9,7 +9,7 @@ buildscript {
jacksonVersion = '2.11.0'
retrofitVersion = "2.8.1" // context: https://stackoverflow.com/questions/60915381/retrofit2-maven-project-illegal-reflective-access-warning // https://github.com/square/retrofit/issues/3341
shadowVersion = '5.2.0'
- ioLibVersion = '2.0.0'
+ ioLibVersion = '2.1.0'
}
}
allprojects {
diff --git a/client/build.gradle b/client/build.gradle
index 7b7ed9ab..33e9140d 100644
--- a/client/build.gradle
+++ b/client/build.gradle
@@ -9,6 +9,7 @@ project.ext.mainClassName = "me.retrodaredevil.solarthing.program.SolarMain"
dependencies {
implementation "com.github.retrodaredevil.io-lib:jSerialComm:$ioLibVersion"
+ implementation "com.github.retrodaredevil.io-lib:purejavacomm:$ioLibVersion"
implementation 'com.fazecast:jSerialComm:2.6.2' // remove this later
implementation group: 'org.influxdb', name: 'influxdb-java', version: '2.15'
implementation group: 'org.mongodb', name: 'mongodb-driver-sync', version: '3.11.0'
diff --git a/client/src/main/java/me/retrodaredevil/solarthing/analytics/AnalyticsManager.java b/client/src/main/java/me/retrodaredevil/solarthing/analytics/AnalyticsManager.java
index b8883bb4..037ab374 100644
--- a/client/src/main/java/me/retrodaredevil/solarthing/analytics/AnalyticsManager.java
+++ b/client/src/main/java/me/retrodaredevil/solarthing/analytics/AnalyticsManager.java
@@ -36,6 +36,7 @@ public AnalyticsManager(boolean isEnabled, File dataDirectory) {
}
if (analyticsData == null) {
analyticsData = new AnalyticsData(UUID.randomUUID());
+ LOGGER.info(SolarThingConstants.SUMMARY_MARKER, "Generated a new Analytics UUID");
try {
MAPPER.writeValue(file, analyticsData);
} catch (IOException e) {
diff --git a/client/src/main/java/me/retrodaredevil/solarthing/config/io/SerialIOConfig.java b/client/src/main/java/me/retrodaredevil/solarthing/config/io/SerialIOConfig.java
index fc8b651b..54ee6765 100644
--- a/client/src/main/java/me/retrodaredevil/solarthing/config/io/SerialIOConfig.java
+++ b/client/src/main/java/me/retrodaredevil/solarthing/config/io/SerialIOConfig.java
@@ -7,6 +7,7 @@
import com.fazecast.jSerialComm.SerialPort;
import me.retrodaredevil.io.IOBundle;
import me.retrodaredevil.io.serial.JSerialIOBundle;
+import me.retrodaredevil.io.serial.PureJavaCommIOBundle;
import me.retrodaredevil.io.serial.SerialConfig;
import me.retrodaredevil.io.serial.SerialConfigBuilder;
import me.retrodaredevil.solarthing.annotations.JsonExplicit;
@@ -29,6 +30,9 @@ public class SerialIOConfig implements IOConfig {
@JsonDeserialize(as = SerialConfigBuilderJackson.class)
private SerialConfig serialConfig;
+ @JsonProperty("purejavacomm")
+ private boolean usePureJavaComm = false;
+
@Override
public IOBundle createIOBundle() throws Exception {
SerialConfig serialConfig = this.serialConfig;
@@ -42,6 +46,9 @@ public IOBundle createIOBundle() throws Exception {
if(port == null){
throw new NullPointerException("null is not a valid value for the port!");
}
+ if (usePureJavaComm) {
+ return PureJavaCommIOBundle.create(port, serialConfig);
+ }
SerialPort serialPort = JSerialIOBundle.createSerialPortFromName(port);
return new JSerialIOBundle(
serialPort,
diff --git a/config_templates/log/remote_log4j2.xml b/config_templates/log/remote_log4j2.xml
new file mode 100644
index 00000000..77a3c0c7
--- /dev/null
+++ b/config_templates/log/remote_log4j2.xml
@@ -0,0 +1,52 @@
+
+
+
+
+ logs
+ %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
+ rw-rw-r--
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/other/docs/log4j.md b/other/docs/log4j.md
new file mode 100644
index 00000000..586ced01
--- /dev/null
+++ b/other/docs/log4j.md
@@ -0,0 +1,18 @@
+# Log4j
+SolarThing uses Log4j2 for logging. (But not the GraphQL program yet, everything else yes)
+
+You can override the default configuration in a few ways:
+
+### `log4j2.xml` in working directory
+When executing `run.sh`, it is configured to detect a file called `log4j2.xml` in the working
+directory. If it finds it, it will use that for the configuration.
+### Environment Variable
+```shell script
+export LOG4j_log4j2_configurationFile=
+```
+### JVM Argument
+```
+java -Dlog4j2.configurationFile= ...
+```
+
+More info: https://stackoverflow.com/questions/778933/log4j-configuration-via-jvm-arguments
diff --git a/other/docs/quickstart.md b/other/docs/quickstart.md
index 7d87a76e..f6c66318 100644
--- a/other/docs/quickstart.md
+++ b/other/docs/quickstart.md
@@ -9,7 +9,7 @@ Run this to quickly get setup (Linux Only):
# This does NOT configure other random files on your system
curl https://raw.githubusercontent.com/wildmountainfarms/solarthing/master/other/linux/clone_install.sh | sudo bash
# If when testing the program, it helps to have permission to edit files owned by the solarthing group, and you will also want to be allowed to use serial ports
-sudo usermod -a -G solarthing,dialout $USER
+sudo usermod -a -G solarthing,dialout,tty,video $USER
```
Or if you want to check out how the **simple** installation works: [click here](../linux/clone_install.sh)
diff --git a/other/docs/simulate_serial.md b/other/docs/simulate_serial.md
new file mode 100644
index 00000000..eb70c451
--- /dev/null
+++ b/other/docs/simulate_serial.md
@@ -0,0 +1,26 @@
+## Simulate Serial
+Here are some commands to help simulate serial
+
+https://stackoverflow.com/questions/52187/virtual-serial-port-for-linux
+
+https://www.onetransistor.eu/2015/12/wine-serial-port-linux.html
+
+```shell script
+sudo socat PTY,link=/dev/ttyS10 PTY,link=/dev/ttyS11
+```
+Connect one end to `/dev/ttyS10` and the other to `/dev/ttyS11`.
+
+Also use this:
+```shell script
+sudo ./diagslave -m rtu -a 1 -b 9600 -p none /dev/ttyS10
+```
+
+If you're doing stuff with wine:
+```shell script
+cd ~/.wine/dosdevices/
+sudo ln -s /dev/ttyS11 com1
+```
+If you're running Solar Station Monitor using Wine:
+```shell script
+wine start 'C:\windows\system32\Solar Station Monitor.exe'
+```
diff --git a/other/docs/updating.md b/other/docs/updating.md
index ff5da6c7..e6738214 100644
--- a/other/docs/updating.md
+++ b/other/docs/updating.md
@@ -14,6 +14,6 @@ If you don't have permission to update, it is recommended you run:
```shell script
sudo other/linux/create_user.sh
sudo other/linux/update_perms.sh
-sudo usermod -a -G solarthing,dialout $USER
+sudo usermod -a -G solarthing,dialout,tty,video $USER
```
This should have already been run if you installed SolarThing using the one line command.
diff --git a/other/linux/create_user.sh b/other/linux/create_user.sh
index 672fb0f4..d62d1165 100755
--- a/other/linux/create_user.sh
+++ b/other/linux/create_user.sh
@@ -19,7 +19,7 @@ fi
# Add user
if ! id -u solarthing >/dev/null 2>&1; then
- useradd -r -g solarthing -G dialout,video solarthing 2>/dev/null # create user with correct groups
+ useradd -r -g solarthing -G dialout,tty,video solarthing 2>/dev/null # create user with correct groups
if ! id -u solarthing >/dev/null 2>&1; then
echo Unable to create user
exit 1
@@ -27,14 +27,13 @@ if ! id -u solarthing >/dev/null 2>&1; then
passwd -l solarthing || (echo Could not lock solarthing passwd; exit 1)
fi
# Add user to groups
-usermod -a -G dialout,video solarthing || exit 1 # add groups to user just to make sure they have all needed groups
-# dialout is for serial port access
+usermod -a -G dialout,tty,video solarthing || exit 1 # add groups to user just to make sure they have all needed groups
+# dialout and tty is for serial port access
# video is for 'vcgencmd' command
echo Created \"solarthing\" user and group.
echo You can add a user to the group with \"adduser \ solarthing\".
echo You need to log out and log back in after adding groups.
-#echo The groups you probably need to be a part of are \(These are the Raspberry Pis default:\):
#echo solarthing adm dialout cdrom sudo audio video plugdev games users input netdev gpio i2c spi
diff --git a/other/solar/README.md b/other/solar/README.md
index 2d8059ca..7d1b981a 100644
--- a/other/solar/README.md
+++ b/other/solar/README.md
@@ -70,6 +70,9 @@ https://www.wmrc.edu/projects/BARenergy/manuals/outback-manuals/MX60_REV_C.pdf
## Renogy References:
Rover manual: https://www.renogy.com/template/files/Manuals/Rover%20203040%20Manual.pdf
+https://renogy.boards.net/thread/565/hp-series-smart-solar-cc
+* "administrator", "111111"
+
Software download: https://www.renogy.com/template/files/Solar%20Station%20Monitor.zip
Modbus protocol: renogy.boards.net/thread/266/rover-modbus
diff --git a/program/.scripts/download_if_needed.sh b/program/.scripts/download_if_needed.sh
index 147a871d..3326d04f 100755
--- a/program/.scripts/download_if_needed.sh
+++ b/program/.scripts/download_if_needed.sh
@@ -2,6 +2,6 @@
BASEDIR=$(dirname "$0")
-if ! ls "$BASEDIR/../solarthing.jar" 2>/dev/null 2>&1; then
+if ! ls "$BASEDIR/../solarthing.jar" 1>/dev/null 2>&1; then
../download_solarthing.sh || exit 1
fi
diff --git a/program/.scripts/solarthing.sh b/program/.scripts/solarthing.sh
index b5d027e3..5bbb6d33 100755
--- a/program/.scripts/solarthing.sh
+++ b/program/.scripts/solarthing.sh
@@ -10,6 +10,11 @@ echo Using base config = "$BASE_CONFIG"
"$BASEDIR/download_if_needed.sh" || exit 1
+if ls log4j2.xml 1>/dev/null 2>&1; then
+ export LOG4J_log4j2_configurationFile=log4j2.xml
+ echo Using log4j2.xml file!
+fi
+
if java --add-opens 2>&1 | grep 'requires modules' >/dev/null; then
java --add-opens=java.base/java.lang.invoke=ALL-UNNAMED -jar "$BASEDIR/../solarthing.jar" "$BASE_CONFIG"
else