diff --git a/api/v2/format/format.h b/api/v2/format/format.h index fbf02d3a810ba1798640056e6f00a4fed808eeab..405c5cd617a42a15ca43fe604b0135a64f46d3e1 100644 --- a/api/v2/format/format.h +++ b/api/v2/format/format.h @@ -12,6 +12,11 @@ #include "../glue/device.h" #include "../transport/transport.h" +typedef union { + eb_data_t data; + eb_address_t address; +} eb_max_align_t; + EB_PRIVATE void eb_device_slave(struct eb_socket* socket, struct eb_transport* transport, eb_device_t devicep, struct eb_device* device); #endif diff --git a/api/v2/format/master.c b/api/v2/format/master.c index 92f31e0a17c25ba828b02ea21931b6cd5083d1ec..6d70d7d89d59d4720694c1c0c5131cd74bd7bf6f 100644 --- a/api/v2/format/master.c +++ b/api/v2/format/master.c @@ -17,6 +17,7 @@ #include "../glue/socket.h" #include "../transport/transport.h" #include "../memory/memory.h" +#include "format.h" static inline void EB_mWRITE(uint8_t* wptr, eb_data_t val, int alignment) { switch (alignment) { @@ -37,7 +38,7 @@ void eb_device_flush(eb_device_t devicep) { eb_cycle_t cyclep, nextp; eb_response_t responsep; eb_width_t biggest, data; - uint8_t buffer[4104]; /* Big enough for an entire record */ + uint8_t buffer[sizeof(eb_max_align_t)*(255+255+1+1)+8]; /* big enough for worst-case record */ uint8_t * wptr, * cptr; int alignment, record_alignment, header_alignment, stride, mtu, readback; diff --git a/api/v2/format/slave.c b/api/v2/format/slave.c index 07e51bec645121b7c9625907343e4852c8d6e00f..68960b47de75b51e286677dfc7bf7a92973290c2 100644 --- a/api/v2/format/slave.c +++ b/api/v2/format/slave.c @@ -38,7 +38,7 @@ void eb_device_slave(struct eb_socket* socket, struct eb_transport* transport, e struct eb_link* link; eb_link_t linkp; int len, keep; - uint8_t buffer[4096]; /* 8*(255+255+1+1) -- big enough for worst-case record without header */ // !!! use sizeof() + uint8_t buffer[sizeof(eb_max_align_t)*(255+255+1+1)]; /* big enough for worst-case record without header */ uint8_t* wptr, * rptr, * eos; uint64_t error; eb_width_t widths, biggest, data;