mirror of
https://github.com/thiagoralves/OpenPLC_v3.git
synced 2026-02-06 19:11:58 +08:00
Fix Simulink hardware layer: remove deprecated pinNotPresent calls
The pinNotPresent function and ignored_* arrays were removed from the
runtime in commit ea789c51, but the Simulink hardware layer was not
updated accordingly. This caused compilation failures when users tried
to use the Simulink driver.
This fix aligns Simulink.cpp with the pattern used in other hardware
layers (raspberrypi.cpp, neuron.cpp, etc.) by:
- Removing the pinNotPresent() calls
- Removing the unused ARRAY_SIZE macro
- Keeping only the NULL pointer checks for I/O buffer access
Co-Authored-By: Thiago Alves <thiagoralves@gmail.com>
This commit is contained in:
@@ -38,10 +38,6 @@
|
||||
|
||||
#include "ladder.h"
|
||||
|
||||
#if !defined(ARRAY_SIZE)
|
||||
#define ARRAY_SIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
#define PORT 6668
|
||||
|
||||
#define ANALOG_BUF_SIZE 8
|
||||
@@ -131,19 +127,13 @@ void *exchangeData(void *arg)
|
||||
pthread_mutex_lock(&bufferLock); //lock mutex
|
||||
for (int i = 0; i < ANALOG_BUF_SIZE; i++)
|
||||
{
|
||||
if (pinNotPresent(ignored_int_inputs, ARRAY_SIZE(ignored_int_inputs), i))
|
||||
if (int_input[i] != NULL) *int_input[i] = plc_data->analogIn[i];
|
||||
|
||||
if (pinNotPresent(ignored_int_outputs, ARRAY_SIZE(ignored_int_outputs), i))
|
||||
if (int_output[i] != NULL) plc_data->analogOut[i] = *int_output[i];
|
||||
if (int_input[i] != NULL) *int_input[i] = plc_data->analogIn[i];
|
||||
if (int_output[i] != NULL) plc_data->analogOut[i] = *int_output[i];
|
||||
}
|
||||
for (int i = 0; i < DIGITAL_BUF_SIZE; i++)
|
||||
{
|
||||
if (pinNotPresent(ignored_bool_inputs, ARRAY_SIZE(ignored_bool_inputs), i))
|
||||
if (bool_input[i/8][i%8] != NULL) *bool_input[i/8][i%8] = plc_data->digitalIn[i];
|
||||
|
||||
if (pinNotPresent(ignored_bool_outputs, ARRAY_SIZE(ignored_bool_outputs), i))
|
||||
if (bool_output[i/8][i%8] != NULL) plc_data->digitalOut[i] = *bool_output[i/8][i%8];
|
||||
if (bool_input[i/8][i%8] != NULL) *bool_input[i/8][i%8] = plc_data->digitalIn[i];
|
||||
if (bool_output[i/8][i%8] != NULL) plc_data->digitalOut[i] = *bool_output[i/8][i%8];
|
||||
}
|
||||
pthread_mutex_unlock(&bufferLock); //unlock mutex
|
||||
|
||||
|
||||
Reference in New Issue
Block a user