Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

electrostatic-sandbox-framework: re-order around platform channels #27

Merged
merged 8 commits into from
Jun 26, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Entry for Electrostatic-Arithmos module.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Entry for Electrostatic-Automata module.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Entry for Electrostatic-DI module.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Entry for Electrostatic-ES module.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,21 @@ extern "C" {
#endif

typedef struct {
char* name;
char *name;
int descriptor;
char* protocol_name;
char* file_system;
char *protocol_name;
char *file_system;
} device_metadata;

typedef struct {
void** (*on_open)(void**);
void** (*on_init)(void**);
void** (*on_deinit)(void**);
void** (*on_read)(void**);
void** (*on_write)(void**);
void** (*on_close)(void**);
} comm_callbacks;

typedef struct {
device_metadata (*open)(void**);
uint8_t (*init)(void**);
Expand All @@ -31,23 +40,29 @@ typedef struct {
uint64_t (*write)(void**);
uint8_t (*close)(void**);
device_metadata (*get_metadata)(void**);
comm_callbacks *callbacks;
} comm_protocol;

/**
* Defines function tables for communication protocols.
*/
enum CommProtocol {
Serial = 0x00,
Parallel = 0x01,
Pci = 0x02,
Sockets = 0x03
SERIAL_RS232 = 0x00,
IEEE_1284 = 0x01,
PCI = 0x02,
NET_SOCKETS = 0x03,
SERIAL_UART = 0x04,
SERIAL_SPI = 0x05,
SERIAL_TWI = 0x06,
SERIAL_CUSTOM_01 = 0x07,
SERIAL_CUSTOM_02 = 0x08
};

extern uint8_t init_protocol(comm_protocol*, const comm_protocol*);
extern uint8_t init_protocol_default(comm_protocol*, enum CommProtocol);
extern uint8_t init_protocol_default(comm_protocol*, enum CommProtocol, const comm_callbacks*);

#ifdef __cplusplus
}
#endif

#endif //_ELECTROSTATIC_COMM_H_
#endif //_ELECTROSTATIC_COMM_H_
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Entry for Electrostatic-Arithmos module.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Entry for Electrostatic-Automata module.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Entry for Electrostatic-DI module.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Entry for Electrostatic-ES module.
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ static device_metadata test_parallel(void** args) {
return metadata;
}

const static comm_protocol serial_table = {
static comm_protocol serial_table = {
&test_serial
};

const static comm_protocol parallel_table = {
static comm_protocol parallel_table = {
&test_parallel
};

extern uint8_t init_protocol(comm_protocol* comm,
const comm_protocol* from) {
extern uint8_t init_protocol(comm_protocol *comm,
const comm_protocol *from) {
if (&from == NULL) {
return -1;
}
Expand All @@ -33,13 +33,16 @@ extern uint8_t init_protocol(comm_protocol* comm,
comm->read = from->read;
comm->write = from->write;
comm->close = from->close;
comm->callbacks = NULL;
return 0;
}

extern uint8_t init_protocol_default(comm_protocol* comm, enum CommProtocol protocol) {
if (protocol == Serial) {
extern uint8_t init_protocol_default(comm_protocol *comm, enum CommProtocol protocol, const comm_callbacks *callbacks) {
if (protocol == SERIAL_RS232) {
serial_table.callbacks = (comm_callbacks*) callbacks;
return init_protocol(comm, &serial_table);
} else if (protocol == Parallel) {
} else if (protocol == IEEE_1284) {
parallel_table.callbacks = callbacks;
return init_protocol(comm, &parallel_table);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<electrofs> directory entry:
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<electrohid> directory entry:
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<electromemory> directory entry:
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<electroparallel> directory entry:
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<electropci> directory entry:
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<electroserial> directory entry:
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<electrosockets> directory entry:
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<electrousbfs> directory entry:
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Entry for Microcontroller Units implementations.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Entry for Utilities.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ comm_protocol serial;
comm_protocol parallel;

int main() {
init_protocol_default(&serial, Serial);
init_protocol_default(&parallel, Parallel);
init_protocol_default(&serial, SERIAL_RS232, NULL);
init_protocol_default(&parallel, IEEE_1284, NULL);
parallel.open(0);
serial.open(0);
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ JNIEXPORT jint JNICALL Java_electrostatic4j_NativeLibrary_open
(JNIEnv* env, jclass clazz, jstring data) {
comm_protocol serial;
comm_protocol parallel;
init_protocol_default(&serial, Serial);
init_protocol_default(&parallel, Parallel);
init_protocol_default(&serial, SERIAL_RS232, NULL);
init_protocol_default(&parallel, IEEE_1284, NULL);
parallel.open(0);
serial.open(0);
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,17 @@ TOOLCHAIN_HEADERS="${4}"
SYSTEM_DIR="${5}"
BUILD_DIR="${6}"

##
# define source modules
##
platform_module="$(pwd)/${source_dir}/dependencies/libs/platform/${SYSTEM_DIR}/"
comm_module="$(pwd)/${source_dir}/dependencies/libs/comm/"
algorithm_module="$(pwd)/${source_dir}/dependencies/libs/algorithm/"
util_module="$(pwd)/${source_dir}/dependencies/libs/util/"

# precompile scripts
sources=$(find "$(pwd)/${source_dir}/src/" -name *.c -o -name *.cpp -o -name *.cxx | tr '\n' ';')
dependencies=$(find "$(pwd)/${source_dir}/dependencies/libs/" -name *.a -o -name *.so -o -name *.ar | tr '\n' ';')
dependencies=$(find "${platform_module}" "${comm_module}" "${algorithm_module}" "${util_module}" -name *.a -o -name *.so -o -name *.ar | tr '\n' ';')

# compile scripts
compile "${COMMISSION_LIB}" "${GCC_BIN}" "${GPP_BIN}" "${INPUT_COMPILER_OPTIONS}" \
Expand Down Expand Up @@ -44,4 +52,4 @@ cp -rv "$(pwd)/${source_dir}/src/include/" \
"$(pwd)/${e4j_dir}/dependencies/"

cp -rv "$(pwd)/${source_dir}/src/include/" \
"$(pwd)/${examples_dir}/dependencies/"
"$(pwd)/${examples_dir}/dependencies/"
Loading