Fix compilation error due to incorrect use of sizeof
This commit is contained in:
parent
ef4e5a310a
commit
6d52302c1d
|
@ -1,5 +1,3 @@
|
|||
#include "ladder.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// DISCLAIMER: EDDITING THIS FILE CAN BREAK YOUR OPENPLC RUNTIME! IF YOU DON'T
|
||||
// KNOW WHAT YOU'RE DOING, JUST DON'T DO IT. EDIT AT YOUR OWN RISK.
|
||||
|
@ -63,4 +61,4 @@ void updateCustomOut()
|
|||
// Important observation: If your I2C pins are used by OpenPLC I/Os, you
|
||||
// must also add those I/Os to the ignored vectors, otherwise OpenPLC
|
||||
// will try to control your I2C pins and your I2C message won't work.
|
||||
}
|
||||
}
|
|
@ -31,6 +31,7 @@
|
|||
#include <pthread.h>
|
||||
|
||||
#include "ladder.h"
|
||||
#include "custom_layer.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// This function is called by the main OpenPLC routine when it is initializing.
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <pthread.h>
|
||||
|
||||
#include "ladder.h"
|
||||
#include "custom_layer.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// This function is called by the main OpenPLC routine when it is initializing.
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <pthread.h>
|
||||
|
||||
#include "ladder.h"
|
||||
#include "custom_layer.h"
|
||||
|
||||
#if !defined(ARRAY_SIZE)
|
||||
#define ARRAY_SIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "ladder.h"
|
||||
#include "custom_layer.h"
|
||||
|
||||
#if !defined(ARRAY_SIZE)
|
||||
#define ARRAY_SIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "ladder.h"
|
||||
#include "custom_layer.h"
|
||||
|
||||
#if !defined(ARRAY_SIZE)
|
||||
#define ARRAY_SIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <pthread.h>
|
||||
|
||||
#include "ladder.h"
|
||||
#include "custom_layer.h"
|
||||
|
||||
#if !defined(ARRAY_SIZE)
|
||||
#define ARRAY_SIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <pthread.h>
|
||||
|
||||
#include "ladder.h"
|
||||
#include "custom_layer.h"
|
||||
|
||||
#if !defined(ARRAY_SIZE)
|
||||
#define ARRAY_SIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <time.h>
|
||||
|
||||
#include "ladder.h"
|
||||
#include "custom_layer.h"
|
||||
|
||||
#if !defined(ARRAY_SIZE)
|
||||
#define ARRAY_SIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <pthread.h>
|
||||
|
||||
#include "ladder.h"
|
||||
#include "custom_layer.h"
|
||||
|
||||
#if !defined(ARRAY_SIZE)
|
||||
#define ARRAY_SIZE(x) (sizeof((x)) / sizeof((x)[0]))
|
||||
|
|
|
@ -93,7 +93,7 @@ void initializeHardware();
|
|||
void updateBuffersIn();
|
||||
void updateBuffersOut();
|
||||
|
||||
//custom_layer.cpp
|
||||
//custom_layer.h
|
||||
void initCustomLayer();
|
||||
void updateCustomIn();
|
||||
void updateCustomOut();
|
||||
|
@ -105,7 +105,7 @@ extern int ignored_int_outputs[];
|
|||
//main.cpp
|
||||
void sleep_until(struct timespec *ts, int delay);
|
||||
void log(unsigned char *logmsg);
|
||||
bool pinNotPresent(int *ignored_vector, int pinNumber);
|
||||
bool pinNotPresent(int *ignored_vector, int vector_size, int pinNumber);
|
||||
extern uint8_t run_openplc;
|
||||
extern unsigned char log_buffer[1000000];
|
||||
extern int log_index;
|
||||
|
|
|
@ -802,14 +802,14 @@ def hardware():
|
|||
<p><b>Hardware Layer Code Box</b><p>
|
||||
<p>The Hardware Layer Code Box allows you to extend the functionality of the current driver by adding custom code to it, such as reading I2C, SPI and 1-Wire sensors, or controling port expanders to add more outputs to your hardware</p>
|
||||
<textarea wrap="off" spellcheck="false" name="custom_layer_code" id="custom_layer_code">"""
|
||||
with open('./core/custom_layer.cpp') as f: return_str += f.read()
|
||||
with open('./core/custom_layer.h') as f: return_str += f.read()
|
||||
return_str += pages.hardware_tail
|
||||
|
||||
else:
|
||||
hardware_layer = flask.request.form['hardware_layer']
|
||||
custom_layer_code = flask.request.form['custom_layer_code']
|
||||
with open('./active_program') as f: current_program = f.read()
|
||||
with open('./core/custom_layer.cpp', 'w+') as f: f.write(custom_layer_code)
|
||||
with open('./core/custom_layer.h', 'w+') as f: f.write(custom_layer_code)
|
||||
|
||||
subprocess.call(['./scripts/change_hardware_layer.sh', hardware_layer])
|
||||
return "<head><meta http-equiv=\"refresh\" content=\"0; URL='compile-program?file=" + current_program + "'\" /></head>"
|
||||
|
@ -826,7 +826,7 @@ def restore_custom_hardware():
|
|||
|
||||
#Restore the original custom layer code
|
||||
with open('./core/custom_layer.original') as f: original_code = f.read()
|
||||
with open('./core/custom_layer.cpp', 'w+') as f: f.write(original_code)
|
||||
with open('./core/custom_layer.h', 'w+') as f: f.write(original_code)
|
||||
return flask.redirect(flask.url_for('hardware'))
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue