This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch refactor/spi3
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/refactor/spi3 by this push:
new f7d048c4ef chore: Removed some accidentally committed files.
f7d048c4ef is described below
commit f7d048c4ef6b19dc3b5c76597e089c849236b5f2
Author: Christofer Dutz <[email protected]>
AuthorDate: Mon Dec 8 09:44:21 2025 +0100
chore: Removed some accidentally committed files.
---
.../plc4x/java/firmata/readwrite/FirmataIT.java | 303 ---------------------
.../firmata/readwrite/TestcontainerSupport.java | 58 ----
.../src/test/resources/firmata/StandardFirmata.ino | 289 --------------------
.../src/test/resources/firmata/libraries.txt | 1 -
4 files changed, 651 deletions(-)
diff --git
a/plc4j/drivers/firmata/src/test/java/org/apache/plc4x/java/firmata/readwrite/FirmataIT.java
b/plc4j/drivers/firmata/src/test/java/org/apache/plc4x/java/firmata/readwrite/FirmataIT.java
deleted file mode 100644
index 12d88cc5ef..0000000000
---
a/plc4j/drivers/firmata/src/test/java/org/apache/plc4x/java/firmata/readwrite/FirmataIT.java
+++ /dev/null
@@ -1,303 +0,0 @@
-package org.apache.plc4x.java.firmata.readwrite;
-
-import com.github.pfichtner.testcontainers.virtualavr.VirtualAvrConnection;
-import com.github.pfichtner.testcontainers.virtualavr.VirtualAvrContainer;
-import org.apache.plc4x.java.api.PlcConnection;
-import org.apache.plc4x.java.api.PlcDriverManager;
-import org.apache.plc4x.java.api.messages.PlcSubscriptionRequest;
-import org.apache.plc4x.java.api.messages.PlcSubscriptionResponse;
-import org.junit.jupiter.api.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testcontainers.images.ImagePullPolicy;
-import org.testcontainers.junit.jupiter.Container;
-import org.testcontainers.junit.jupiter.Testcontainers;
-import org.testcontainers.utility.DockerImageName;
-
-import java.io.File;
-import java.net.URISyntaxException;
-import java.util.List;
-import java.util.Objects;
-import java.util.UUID;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-/**
- * Integration test for the Firmata driver using VirtualAVR in TestContainers.
- * <p>
- * This test simulates:
- * - Analog input (A0): Sine wave from 0 to 1023
- * - Digital inputs (pins 2-5): 4-bit counter cycling 0-15
- * <p>
- * The test verifies that the Firmata driver correctly receives these values
- * through subscriptions.
- * <p>
- * NOTE: Each test uses @TestInstance(PER_METHOD) with @Container to get a
fresh
- * container instance. This is necessary because the socat TCP-to-PTY bridge on
- * macOS doesn't handle connection reuse well, and the Arduino needs a clean
state
- * for each test.
- */
-@Testcontainers(disabledWithoutDocker = true)
-@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
-public class FirmataIT {
-
- private static final Logger LOGGER =
LoggerFactory.getLogger(FirmataIT.class);
-
- // Pin configuration
- private static final String ANALOG_PIN_A0 = "A0"; // Analog pin for sine
wave
- private static final int[] DIGITAL_PINS = {2, 3, 4, 5}; // 4 digital pins
for counter
-
- // Simulation parameters
- private static final double SINE_WAVE_PERIOD_MS = 2000; // 2-second period
- private static final int COUNTER_INCREMENT_MS = 500; // Increment every
500ms
-
- // Container is created fresh for each test method
- @Container
- VirtualAvrContainer<?> virtualavr =
TestcontainerSupport.virtualAvrContainer(loadClasspath("/firmata/StandardFirmata.ino"))
- .withBaudrate(57600);
-
- static File loadClasspath(String name) {
- try {
- return new
File(Objects.requireNonNull(FirmataIT.class.getResource(name)).toURI());
- } catch (URISyntaxException e) {
- throw new IllegalStateException(e);
- }
- }
-
- private ScheduledExecutorService simulationExecutor;
- private ScheduledFuture<?> sineWaveFuture;
- private ScheduledFuture<?> counterFuture;
-
- @BeforeEach
- void setup() {
- simulationExecutor = Executors.newScheduledThreadPool(2);
- startSimulation();
- }
-
- @AfterEach
- void teardown() {
- stopSimulation();
- if (simulationExecutor != null) {
- simulationExecutor.shutdown();
- try {
- if (!simulationExecutor.awaitTermination(5, TimeUnit.SECONDS))
{
- simulationExecutor.shutdownNow();
- }
- } catch (InterruptedException e) {
- simulationExecutor.shutdownNow();
- Thread.currentThread().interrupt();
- }
- LOGGER.info("Simulation executor terminated");
- }
- }
-
- /**
- * Start the pin value simulation.
- * - Sine wave on analog pin A0 (0-1023)
- * - 4-bit counter on digital pins 2-5 (0-15)
- */
- private void startSimulation() {
- VirtualAvrConnection avrConnection = virtualavr.avr();
-
- // Sine wave simulation on A0
- AtomicInteger sinePhase = new AtomicInteger(0);
- sineWaveFuture = simulationExecutor.scheduleAtFixedRate(() -> {
- try {
- int phase = sinePhase.getAndIncrement();
- double radians = (2 * Math.PI * phase) / (SINE_WAVE_PERIOD_MS
/ 100);
- int value = (int) ((Math.sin(radians) + 1) * 511.5); // Map
-1..1 to 0..1023
- avrConnection.pinState(ANALOG_PIN_A0, value);
- LOGGER.debug("Sine wave: phase={}, value={}", phase, value);
- } catch (Exception e) {
- LOGGER.error("Error in sine wave simulation", e);
- }
- }, 0, 50, TimeUnit.MILLISECONDS);
-
- // Counter simulation on digital pins
- AtomicInteger counter = new AtomicInteger(0);
- counterFuture = simulationExecutor.scheduleAtFixedRate(() -> {
- try {
- int count = counter.getAndIncrement() % 16;
- for (int i = 0; i < DIGITAL_PINS.length; i++) {
- boolean bitValue = ((count >> i) & 1) == 1;
- avrConnection.pinState(String.valueOf(DIGITAL_PINS[i]),
bitValue);
- }
- LOGGER.debug("Counter: {} (binary: {})", count,
Integer.toBinaryString(count));
- } catch (Exception e) {
- LOGGER.error("Error in counter simulation", e);
- }
- }, 0, COUNTER_INCREMENT_MS, TimeUnit.MILLISECONDS);
-
- LOGGER.info("Simulation started: Sine wave on {}, Counter on pins
{}-{}",
- ANALOG_PIN_A0, DIGITAL_PINS[0], DIGITAL_PINS[DIGITAL_PINS.length -
1]);
- }
-
- private void stopSimulation() {
- // Cancel any running scheduled tasks
- if (sineWaveFuture != null) {
- sineWaveFuture.cancel(false);
- sineWaveFuture = null;
- }
- if (counterFuture != null) {
- counterFuture.cancel(false);
- counterFuture = null;
- }
- }
-
- @Test
- @Order(1)
- @DisplayName("Test analog pins (sine wave simulation)")
- void testAnalogInputs() throws Exception {
- String serialDevicePath = virtualavr.serialPortDescriptor();
- LOGGER.info("Started virtual serial port on {}", serialDevicePath);
-
- boolean received;
- List<Integer> receivedValues = new CopyOnWriteArrayList<>();
- CountDownLatch valuesReceived = new CountDownLatch(20);
-
- // Create a connection using the serialDevicePath and subscribe to
analog pin A0
- try (PlcConnection connection =
PlcDriverManager.getDefault().getConnectionManager().getConnection("firmata://"
+ serialDevicePath + "?serial.baud-rate=57600")) {
//&log.driver-testsuite-file=audit-log.txt
- PlcSubscriptionResponse subscriptionResponse =
connection.subscriptionRequestBuilder()
- .addChangeOfStateTagAddress(ANALOG_PIN_A0, "analog:0",
plcSubscriptionEvent -> {
- LOGGER.info("Received event: {}",
plcSubscriptionEvent.getPlcValue(ANALOG_PIN_A0).getInteger());
-
receivedValues.add(plcSubscriptionEvent.getPlcValue(ANALOG_PIN_A0).getInteger());
- valuesReceived.countDown();
- })
- .build()
- .execute().get(1000, TimeUnit.MILLISECONDS);
-
- // Wait for values (longer timeout for QEMU emulation)
- received = valuesReceived.await(15, TimeUnit.SECONDS);
-
- // Unsubscribe from all subscriptions
- connection.unsubscriptionRequestBuilder()
- .addHandles(subscriptionResponse.getSubscriptionHandles());
- }
-
- assertTrue(received || receivedValues.size() > 5,
- "Should receive multiple analog values");
-
- // Verify values are in the expected range
- for (int value : receivedValues) {
- assertTrue(value >= 0 && value <= 1023,
- "Analog value should be between 0 and 1023, got: " + value);
- }
-
- // Verify we see variation (sine wave should produce different values)
- if (receivedValues.size() > 5) {
- int min =
receivedValues.stream().mapToInt(Integer::intValue).min().orElse(0);
- int max =
receivedValues.stream().mapToInt(Integer::intValue).max().orElse(1023);
- assertTrue(max - min > 100,
- "Should see significant variation in sine wave values");
- }
-
- LOGGER.info("Received {} analog values, range: {} to {}",
- receivedValues.size(),
-
receivedValues.stream().mapToInt(Integer::intValue).min().orElse(-1),
-
receivedValues.stream().mapToInt(Integer::intValue).max().orElse(-1));
- }
-
- @Test
- @Order(2)
- @DisplayName("Test digital pins (4-bit counter simulation)")
- void testDigitalInputs() throws Exception {
- String serialDevicePath = virtualavr.serialPortDescriptor();
- LOGGER.info("Started virtual serial port on {}", serialDevicePath);
-
- boolean received;
- List<Integer> receivedCounterValues = new CopyOnWriteArrayList<>();
- CountDownLatch valuesReceived = new CountDownLatch(16);
-
- // Create a connection using the serialDevicePath and subscribe to
digital pins
- try (PlcConnection connection =
PlcDriverManager.getDefault().getConnectionManager().getConnection("firmata://"
+ serialDevicePath +
"?serial.baud-rate=57600&log.driver-testsuite-file=audit-log.txt")) {
- PlcSubscriptionRequest.Builder builder =
connection.subscriptionRequestBuilder();
- for (int pin : DIGITAL_PINS) {
- builder.addChangeOfStateTagAddress(String.valueOf(pin),
"digital:" + pin);
- }
- builder.setConsumer(plcSubscriptionEvent -> {
- LOGGER.info("Received event: {}", plcSubscriptionEvent);
- for (String tagName : plcSubscriptionEvent.getTagNames()) {
- int integer =
plcSubscriptionEvent.getPlcValue(tagName).getInteger();
- receivedCounterValues.add(integer);
- }
- valuesReceived.countDown();
- });
- PlcSubscriptionResponse subscriptionResponse = builder
- .build()
- .execute().get(1000, TimeUnit.MILLISECONDS);
-
- // Wait for values (longer timeout for QEMU emulation)
- received = valuesReceived.await(15, TimeUnit.SECONDS);
-
- // Unsubscribe from all subscriptions
- connection.unsubscriptionRequestBuilder()
- .addHandles(subscriptionResponse.getSubscriptionHandles())
- .build().execute().get(1000, TimeUnit.MILLISECONDS);
- }
-
- assertTrue(received || receivedCounterValues.size() > 3,
- "Should receive multiple counter values");
-
- // Verify values are in the expected range (0-15)
- for (int value : receivedCounterValues) {
- assertTrue(value >= 0 && value <= 15,
- "Counter value should be between 0 and 15, got: " + value);
- }
-
- LOGGER.info("Received {} counter state changes",
receivedCounterValues.size());
- }
-
- @Test
- @Order(3)
- @DisplayName("Test combined analog and digital pins")
- void testAnalogAndDigitalInputs() throws Exception {
- String serialDevicePath = virtualavr.serialPortDescriptor();
- LOGGER.info("Started virtual serial port on {}", serialDevicePath);
-
- boolean received;
- AtomicInteger analogCount = new AtomicInteger(0);
- AtomicInteger digitalCount = new AtomicInteger(0);
- CountDownLatch valuesReceived = new CountDownLatch(10);
-
- // Create a connection using the serialDevicePath and subscribe to
both analog and digital pins
- try (PlcConnection connection =
PlcDriverManager.getDefault().getConnectionManager().getConnection("firmata://"
+ serialDevicePath +
"?serial.baud-rate=57600&log.driver-testsuite-file=audit-log.txt")) {
- PlcSubscriptionRequest.Builder builder =
connection.subscriptionRequestBuilder();
- for (int pin : DIGITAL_PINS) {
- builder.addChangeOfStateTagAddress("D" + pin, "digital:" +
pin);
- }
- builder.addChangeOfStateTagAddress(ANALOG_PIN_A0, "analog:0");
- builder.setConsumer(plcSubscriptionEvent -> {
- LOGGER.info("Received event: {}", plcSubscriptionEvent);
- for (String tagName : plcSubscriptionEvent.getTagNames()) {
- if (tagName.equals(ANALOG_PIN_A0)) {
- analogCount.incrementAndGet();
- } else if (tagName.startsWith("D")) {
- digitalCount.incrementAndGet();
- }
- }
- valuesReceived.countDown();
- });
- PlcSubscriptionResponse subscriptionResponse = builder
- .build()
- .execute().get(1000, TimeUnit.MILLISECONDS);
-
- // Wait for values (longer timeout for QEMU emulation)
- received = valuesReceived.await(15, TimeUnit.SECONDS);
-
- // Unsubscribe from all subscriptions
- connection.unsubscriptionRequestBuilder()
- .addHandles(subscriptionResponse.getSubscriptionHandles())
- .build().execute().get(1000, TimeUnit.MILLISECONDS);
- }
-
- LOGGER.info("Received {} analog events and {} digital events",
- analogCount.get(), digitalCount.get());
-
- // Both simulation types should have produced events
- assertTrue(received && (analogCount.get() > 0 || digitalCount.get() >
0),
- "Should receive events from both analog and digital simulations");
- }
-
-}
diff --git
a/plc4j/drivers/firmata/src/test/java/org/apache/plc4x/java/firmata/readwrite/TestcontainerSupport.java
b/plc4j/drivers/firmata/src/test/java/org/apache/plc4x/java/firmata/readwrite/TestcontainerSupport.java
deleted file mode 100644
index a752d97fd6..0000000000
---
a/plc4j/drivers/firmata/src/test/java/org/apache/plc4x/java/firmata/readwrite/TestcontainerSupport.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package org.apache.plc4x.java.firmata.readwrite;
-
-import com.github.pfichtner.testcontainers.virtualavr.VirtualAvrContainer;
-import org.testcontainers.images.ImagePullPolicy;
-import org.testcontainers.utility.DockerImageName;
-
-import java.io.File;
-import java.util.UUID;
-
-public final class TestcontainerSupport {
-
- private static final String VIRTUALAVR_DOCKER_TAG_PROPERTY_NAME =
"virtualavr.docker.tag";
- private static final String VIRTUALAVR_DOCKER_PULL_PROPERTY_NAME =
"virtualavr.docker.pull";
-
- private TestcontainerSupport() {
- super();
- }
-
- @SuppressWarnings("resource")
- public static VirtualAvrContainer<?> virtualAvrContainer(File inoFile) {
- VirtualAvrContainer<?> container = new
VirtualAvrContainer<>(imageName()) //
- .withImagePullPolicy(onlyPullIfEnabled()) //
- .withSketchFile(inoFile) //
- .withDeviceName("virtualavr" +
UUID.randomUUID()) //
- .withDeviceGroup("root") //
- .withDeviceMode(666);
-
- // Use TCP serial mode on non-Linux systems (macOS/Windows with
Docker Desktop)
- if (!isLinux()) {
- container.withTcpSerialMode();
- }
-
- return container;
- }
-
- public static ImagePullPolicy onlyPullIfEnabled() {
- return imageName ->
System.getProperty(VIRTUALAVR_DOCKER_PULL_PROPERTY_NAME) != null;
- }
-
- public static DockerImageName imageName() {
- String dockerTagName =
System.getProperty(VIRTUALAVR_DOCKER_TAG_PROPERTY_NAME, "dev");
- DockerImageName defaultImageName =
VirtualAvrContainer.DEFAULT_IMAGE_NAME;
- return dockerTagName == null ? defaultImageName :
defaultImageName.withTag(dockerTagName);
- }
-
- /**
- * Checks if the current OS is Linux.
- * On Linux, the standard PTY mode works because /dev can be
bind-mounted.
- * On macOS/Windows with Docker Desktop, TCP serial mode is needed.
- *
- * @return true if running on Linux
- */
- public static boolean isLinux() {
- String os = System.getProperty("os.name", "").toLowerCase();
- return os.contains("linux");
- }
-
-}
diff --git
a/plc4j/drivers/firmata/src/test/resources/firmata/StandardFirmata.ino
b/plc4j/drivers/firmata/src/test/resources/firmata/StandardFirmata.ino
deleted file mode 100644
index 5604f3aa2e..0000000000
--- a/plc4j/drivers/firmata/src/test/resources/firmata/StandardFirmata.ino
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * StandardFirmata sketch for VirtualAVR integration testing.
- * This is a minimal Firmata implementation that works with avr8js simulator.
- *
- * Based on StandardFirmata by Firmata (LGPL v2.1+)
- * Simplified for testing purposes.
- *
- * Debug output: The built-in LED (pin 13) blinks when Firmata commands are
received.
- * Analog changes are indicated by PWM on pin 9 (proportional to A0 value).
- */
-
-#include <Firmata.h>
-
-/* Debug LED for visual feedback */
-#define DEBUG_LED 13
-#define DEBUG_PWM 9
-
-/* Command counters for debugging */
-volatile unsigned int commandCount = 0;
-volatile unsigned int analogChangeCount = 0;
-
-/* analog inputs */
-int analogInputsToReport = 0; // bitwise array to store pin reporting
-int lastAnalogValues[16];
-
-/* digital input ports */
-byte reportPINs[TOTAL_PORTS]; // 1 = report this port, 0 = silence
-byte previousPINs[TOTAL_PORTS]; // previous 8 bits sent
-
-/* pins configuration */
-byte pinConfig[TOTAL_PINS]; // configuration of every pin
-byte portConfigInputs[TOTAL_PORTS]; // each bit: 1 = pin in INPUT, 0 =
anything else
-
-/* timer variables */
-unsigned long currentMillis; // store the current value from millis()
-unsigned long previousMillis; // for comparison with currentMillis
-unsigned int samplingInterval = 19; // how often to sample analog inputs (in
ms)
-
-/* Debug: Toggle LED to indicate activity */
-void debugBlink() {
- static bool ledState = false;
- ledState = !ledState;
- digitalWrite(DEBUG_LED, ledState ? HIGH : LOW);
- commandCount++;
-}
-
-/* Debug: Show analog value on PWM pin */
-void debugAnalog(int value) {
- // Map 0-1023 to 0-255 for PWM
- analogWrite(DEBUG_PWM, value >> 2);
- analogChangeCount++;
-}
-
-void outputPort(byte portNumber, byte portValue, byte forceSend)
-{
- portValue = portValue & portConfigInputs[portNumber];
- if (forceSend || previousPINs[portNumber] != portValue) {
- Firmata.sendDigitalPort(portNumber, portValue);
- previousPINs[portNumber] = portValue;
- }
-}
-
-void checkDigitalInputs(void)
-{
- if (TOTAL_PORTS > 0 && reportPINs[0]) outputPort(0, readPort(0,
portConfigInputs[0]), false);
- if (TOTAL_PORTS > 1 && reportPINs[1]) outputPort(1, readPort(1,
portConfigInputs[1]), false);
- if (TOTAL_PORTS > 2 && reportPINs[2]) outputPort(2, readPort(2,
portConfigInputs[2]), false);
-}
-
-void setPinModeCallback(byte pin, int mode)
-{
- debugBlink(); // Visual feedback for received command
- if (pin < TOTAL_PINS) {
- pinConfig[pin] = mode;
-
- if (mode == PIN_MODE_INPUT || mode == PIN_MODE_PULLUP) {
- portConfigInputs[pin / 8] |= (1 << (pin & 7));
- if (mode == PIN_MODE_PULLUP) {
- digitalWrite(pin, HIGH);
- }
- pinMode(pin, INPUT);
- } else if (mode == PIN_MODE_OUTPUT) {
- portConfigInputs[pin / 8] &= ~(1 << (pin & 7));
- pinMode(pin, OUTPUT);
- } else if (mode == PIN_MODE_ANALOG) {
- portConfigInputs[pin / 8] &= ~(1 << (pin & 7));
- } else if (mode == PIN_MODE_PWM) {
- portConfigInputs[pin / 8] &= ~(1 << (pin & 7));
- pinMode(pin, OUTPUT);
- }
- }
-}
-
-void setDigitalPinValueCallback(byte pin, int value)
-{
- debugBlink(); // Visual feedback for received command
- if (pin < TOTAL_PINS && pinConfig[pin] == PIN_MODE_OUTPUT) {
- digitalWrite(pin, value);
- }
-}
-
-void analogWriteCallback(byte pin, int value)
-{
- debugBlink(); // Visual feedback for received command
- if (pin < TOTAL_PINS) {
- switch (pinConfig[pin]) {
- case PIN_MODE_PWM:
- analogWrite(pin, value);
- break;
- }
- }
-}
-
-void digitalWriteCallback(byte port, int value)
-{
- debugBlink(); // Visual feedback for received command
- byte pin, lastPin, mask = 1, pinWriteMask = 0;
-
- if (port < TOTAL_PORTS) {
- lastPin = port * 8 + 8;
- if (lastPin > TOTAL_PINS) lastPin = TOTAL_PINS;
-
- for (pin = port * 8; pin < lastPin; pin++) {
- if (pinConfig[pin] == PIN_MODE_OUTPUT) {
- pinWriteMask |= mask;
- }
- mask = mask << 1;
- }
- writePort(port, (byte)value, pinWriteMask);
- }
-}
-
-void reportAnalogCallback(byte analogPin, int value)
-{
- debugBlink(); // Visual feedback for received command
- if (analogPin < TOTAL_ANALOG_PINS) {
- if (value == 0) {
- analogInputsToReport &= ~(1 << analogPin);
- } else {
- analogInputsToReport |= (1 << analogPin);
- }
- }
-}
-
-void reportDigitalCallback(byte port, int value)
-{
- debugBlink(); // Visual feedback for received command
- if (port < TOTAL_PORTS) {
- reportPINs[port] = (byte)value;
- if (value) outputPort(port, readPort(port, portConfigInputs[port]), true);
- }
-}
-
-void sysexCallback(byte command, byte argc, byte *argv)
-{
- switch (command) {
- case SAMPLING_INTERVAL:
- if (argc > 1) {
- samplingInterval = argv[0] + (argv[1] << 7);
- if (samplingInterval < 10) {
- samplingInterval = 10;
- }
- }
- break;
- case CAPABILITY_QUERY:
- Firmata.write(START_SYSEX);
- Firmata.write(CAPABILITY_RESPONSE);
- for (byte pin = 0; pin < TOTAL_PINS; pin++) {
- if (IS_PIN_DIGITAL(pin)) {
- Firmata.write((byte)PIN_MODE_INPUT);
- Firmata.write(1);
- Firmata.write((byte)PIN_MODE_PULLUP);
- Firmata.write(1);
- Firmata.write((byte)PIN_MODE_OUTPUT);
- Firmata.write(1);
- }
- if (IS_PIN_ANALOG(pin)) {
- Firmata.write(PIN_MODE_ANALOG);
- Firmata.write(10); // 10-bit resolution
- }
- if (IS_PIN_PWM(pin)) {
- Firmata.write(PIN_MODE_PWM);
- Firmata.write(8); // 8-bit resolution
- }
- Firmata.write(127);
- }
- Firmata.write(END_SYSEX);
- break;
- case PIN_STATE_QUERY:
- if (argc > 0) {
- byte pin = argv[0];
- Firmata.write(START_SYSEX);
- Firmata.write(PIN_STATE_RESPONSE);
- Firmata.write(pin);
- if (pin < TOTAL_PINS) {
- Firmata.write((byte)pinConfig[pin]);
- if (pinConfig[pin] == PIN_MODE_OUTPUT) {
- Firmata.write((byte)digitalRead(pin));
- }
- }
- Firmata.write(END_SYSEX);
- }
- break;
- case ANALOG_MAPPING_QUERY:
- Firmata.write(START_SYSEX);
- Firmata.write(ANALOG_MAPPING_RESPONSE);
- for (byte pin = 0; pin < TOTAL_PINS; pin++) {
- Firmata.write(IS_PIN_ANALOG(pin) ? PIN_TO_ANALOG(pin) : 127);
- }
- Firmata.write(END_SYSEX);
- break;
- }
-}
-
-void systemResetCallback()
-{
- for (byte i = 0; i < TOTAL_PORTS; i++) {
- reportPINs[i] = false;
- portConfigInputs[i] = 0;
- previousPINs[i] = 0;
- }
- for (byte i = 0; i < TOTAL_PINS; i++) {
- pinConfig[i] = PIN_MODE_OUTPUT;
- }
- for (byte i = 0; i < TOTAL_ANALOG_PINS; i++) {
- lastAnalogValues[i] = 0;
- }
- analogInputsToReport = 0;
-}
-
-void setup()
-{
- // Initialize debug pins
- pinMode(DEBUG_LED, OUTPUT);
- pinMode(DEBUG_PWM, OUTPUT);
- digitalWrite(DEBUG_LED, LOW);
-
- // Blink LED 3 times to indicate startup
- for (int i = 0; i < 3; i++) {
- digitalWrite(DEBUG_LED, HIGH);
- delay(100);
- digitalWrite(DEBUG_LED, LOW);
- delay(100);
- }
-
- Firmata.setFirmwareVersion(FIRMATA_FIRMWARE_MAJOR_VERSION,
FIRMATA_FIRMWARE_MINOR_VERSION);
-
- Firmata.attach(ANALOG_MESSAGE, analogWriteCallback);
- Firmata.attach(DIGITAL_MESSAGE, digitalWriteCallback);
- Firmata.attach(REPORT_ANALOG, reportAnalogCallback);
- Firmata.attach(REPORT_DIGITAL, reportDigitalCallback);
- Firmata.attach(SET_PIN_MODE, setPinModeCallback);
- Firmata.attach(SET_DIGITAL_PIN_VALUE, setDigitalPinValueCallback);
- Firmata.attach(START_SYSEX, sysexCallback);
- Firmata.attach(SYSTEM_RESET, systemResetCallback);
-
- Firmata.begin(57600);
- systemResetCallback();
-}
-
-void loop()
-{
- byte pin, analogPin;
-
- checkDigitalInputs();
-
- currentMillis = millis();
- if (currentMillis - previousMillis >= samplingInterval) {
- previousMillis = currentMillis;
-
- for (pin = 0; pin < TOTAL_ANALOG_PINS; pin++) {
- if (analogInputsToReport & (1 << pin)) {
- int value = analogRead(pin);
- if (value != lastAnalogValues[pin]) {
- Firmata.sendAnalog(pin, value);
- lastAnalogValues[pin] = value;
- // Debug: Show analog value changes on PWM pin 9
- if (pin == 0) {
- debugAnalog(value);
- }
- }
- }
- }
- }
-
- while (Firmata.available()) {
- Firmata.processInput();
- }
-}
diff --git a/plc4j/drivers/firmata/src/test/resources/firmata/libraries.txt
b/plc4j/drivers/firmata/src/test/resources/firmata/libraries.txt
deleted file mode 100644
index 8520e92714..0000000000
--- a/plc4j/drivers/firmata/src/test/resources/firmata/libraries.txt
+++ /dev/null
@@ -1 +0,0 @@
-Firmata