From 0dc9433408c0ef1ccb4c8ee5e9f6dc328df3d00d Mon Sep 17 00:00:00 2001 From: Torsten Oltmanns Date: Wed, 3 Jan 2024 10:46:24 +0800 Subject: [PATCH] moved utility scripts to new folder --- bms-to-inverter-main/pom.xml | 16 ++++++++-------- .../bmstoinverter/protocol/can/JavaCANPort.java | 3 +++ cleanrepo.sh => scripts/cleanrepo.sh | 6 +++--- .../config.properties.mine | 9 +++++---- log4j2.xml.mine => scripts/log4j2.xml.mine | 0 pom.xml.mine => scripts/pom.xml.mine | 0 scripts/startcan.sh | 7 +++++++ 7 files changed, 26 insertions(+), 15 deletions(-) rename cleanrepo.sh => scripts/cleanrepo.sh (50%) rename config.properties.mine => scripts/config.properties.mine (96%) rename log4j2.xml.mine => scripts/log4j2.xml.mine (100%) rename pom.xml.mine => scripts/pom.xml.mine (100%) create mode 100644 scripts/startcan.sh diff --git a/bms-to-inverter-main/pom.xml b/bms-to-inverter-main/pom.xml index cdf66590..0312d8f0 100644 --- a/bms-to-inverter-main/pom.xml +++ b/bms-to-inverter-main/pom.xml @@ -91,18 +91,18 @@ - - - - - - - com.ai-republic.bms-to-inverter - bms-daly-rs485 + bms-daly-can ${project.version} + + + + + + + diff --git a/protocol-can/src/main/java/com/airepublic/bmstoinverter/protocol/can/JavaCANPort.java b/protocol-can/src/main/java/com/airepublic/bmstoinverter/protocol/can/JavaCANPort.java index aca7e81b..9c72fd6a 100644 --- a/protocol-can/src/main/java/com/airepublic/bmstoinverter/protocol/can/JavaCANPort.java +++ b/protocol-can/src/main/java/com/airepublic/bmstoinverter/protocol/can/JavaCANPort.java @@ -66,7 +66,9 @@ public boolean isOpen() { public ByteBuffer receiveFrame(final Predicate validator) throws IOException { ensureOpen(); + LOG.debug("CAN frame read..."); final CanFrame frame = canChannel.read(); + LOG.debug("CAN read frame {}", printBuffer(frame.getBuffer())); final ByteBuffer buffer = frame.getBuffer(); buffer.rewind(); buffer.putInt(frame.getId()); @@ -100,6 +102,7 @@ public void sendExtendedFrame(final ByteBuffer frame) throws IOException { final CanFrame sendFrame = CanFrame.createExtended(frameId, flags, data, 0, length); canChannel.write(sendFrame); + LOG.debug("CAN frame sent: {}", printBuffer(sendFrame.getBuffer())); } diff --git a/cleanrepo.sh b/scripts/cleanrepo.sh similarity index 50% rename from cleanrepo.sh rename to scripts/cleanrepo.sh index 1240eb2f..cb4ecf4b 100644 --- a/cleanrepo.sh +++ b/scripts/cleanrepo.sh @@ -3,9 +3,9 @@ cd ~/bms-to-inverter git restore * git pull -cp ~/bms-to-inverter/pom.xml.mine ~/bms-to-inverter/bms-to-inverter-main/pom.xml -cp ~/bms-to-inverter/config.properties.mine ~/bms-to-inverter/bms-to-inverter-main/src/main/resources/config.properties -cp ~/bms-to-inverter/log4j2.xml.mine ~/bms-to-inverter/bms-to-inverter-main/src/main/resources/log4j2.xml +cp ~/pom.xml.mine ~/bms-to-inverter/bms-to-inverter-main/pom.xml +cp ~/config.properties.mine ~/bms-to-inverter/bms-to-inverter-main/src/main/resources/config.properties +cp ~/log4j2.xml.mine ~/bms-to-inverter/bms-to-inverter-main/src/main/resources/log4j2.xml mvn clean package -DskipTests rm -R ~/final diff --git a/config.properties.mine b/scripts/config.properties.mine similarity index 96% rename from config.properties.mine rename to scripts/config.properties.mine index cf06a028..d088f86c 100644 --- a/config.properties.mine +++ b/scripts/config.properties.mine @@ -26,14 +26,14 @@ ModBus.baudrate=9600 #### Simple single port configuration #### # BMS port protocol (CAN/RS485/ModBus) -bms.portProtocol=RS485 -#bms.portProtocol=CAN +#bms.portProtocol=RS485 +bms.portProtocol=CAN # The port name/device to use to communicate to the BMS #bms.portLocator=com3 -#bms.portLocator=can0 +bms.portLocator=can0 #bms.portLocator=/dev/ttyS0 -bms.portLocator=/dev/ttyUSB0 +#bms.portLocator=/dev/ttyUSB0 #### Or for multiple BMSes connected to multiple ports #### #bms.0.portProtocol=CAN @@ -54,6 +54,7 @@ bms.pollInterval=60 # The port name/device to use to communicate to the inverter inverter.portLocator=can1 + # Interval to send data to the inverter (in seconds) inverter.sendInterval=1 diff --git a/log4j2.xml.mine b/scripts/log4j2.xml.mine similarity index 100% rename from log4j2.xml.mine rename to scripts/log4j2.xml.mine diff --git a/pom.xml.mine b/scripts/pom.xml.mine similarity index 100% rename from pom.xml.mine rename to scripts/pom.xml.mine diff --git a/scripts/startcan.sh b/scripts/startcan.sh new file mode 100644 index 00000000..c2cb31bc --- /dev/null +++ b/scripts/startcan.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +sudo ip link set can0 type can bitrate 500000 restart-ms 100 fd off +sudo ip link set can1 type can bitrate 500000 restart-ms 100 fd off +sudo ifconfig can0 txqueuelen 65536 +sudo ifconfig can1 txqueuelen 65536 +sudo ip link set up can0 +sudo ip link set up can1 \ No newline at end of file