Just allowing message with 1 frame avoiding to handle dynamic sized array...
This close the door for multiplexed msg for now... Let's see later and move on
Change-Id: I3626d4b6634b3f119826603e64713d63e994918e
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
{
uint32_t can_id = s.get_message().get_id();
{
uint32_t can_id = s.get_message().get_id();
- struct utils::basic_bcm_msg<struct can_frame> bcm_msg;
+ struct utils::simple_bcm_msg bcm_msg;
struct can_frame cfd;
memset(&cfd, 0, sizeof(cfd));
struct can_frame cfd;
memset(&cfd, 0, sizeof(cfd));
- bcm_msg.frames.push_back(cfd);
if(can_socket_ << bcm_msg)
return 0;
if(can_socket_ << bcm_msg)
return 0;
-
- socketcan_t& operator<<(socketcan_t& s, const struct basic_bcm_msg<struct can_frame>& obj)
- {
- s << obj.msg_head;
- s << obj.frames;
- return s;
- }
-
- socketcan_t& operator<<(socketcan_t& s, const struct canfd_bcm_msg& obj)
- {
- s << obj.msg_head;
- s << obj.frames;
- return s;
- }
}
\ No newline at end of file
}
\ No newline at end of file
#include "low-can-binding.hpp"
#define INVALID_SOCKET -1
#include "low-can-binding.hpp"
#define INVALID_SOCKET -1
-#define U64_DATA(p) (*(unsigned long long*)(p)->data)
-
- template <typename T>
- struct basic_bcm_msg
{
struct bcm_msg_head msg_head;
{
struct bcm_msg_head msg_head;
+ struct can_frame frames;
- struct canfd_bcm_msg : public basic_bcm_msg<canfd_frame>
- canfd_bcm_msg() { msg_head.flags |= CAN_FD_FRAME; }
+ struct bcm_msg_head msg_head;
+ struct canfd_frame frames;
+ canfd_bcm_msg() { msg_head.flags |= CAN_FD_FRAME; }
- socketcan_t& operator<<(socketcan_t& s, const struct basic_bcm_msg<can_frame>& obj);
+
+ template <typename T>
+ socketcan_t& operator<<(socketcan_t& s, const T& obj)
+ {
+ if (::sendto(s.socket(), &obj, sizeof(obj), 0, (const struct sockaddr*)&s.get_tx_address(), sizeof(s.get_tx_address())) < 0)
+ ERROR(binder_interface, "%s: Error sending : %i %s", __FUNCTION__, errno, ::strerror(errno));
+ return s;
+ }
+
+ socketcan_t& operator<<(socketcan_t& s, const struct simple_bcm_msg& obj);
socketcan_t& operator<<(socketcan_t& s, const struct canfd_bcm_msg& obj);
socketcan_t& operator>>(socketcan_t& s, can_message_t& cm);
socketcan_t& operator<<(socketcan_t& s, const struct canfd_bcm_msg& obj);
socketcan_t& operator>>(socketcan_t& s, can_message_t& cm);