aboutsummaryrefslogtreecommitdiffstats
path: root/low-can-binding/can/can-encoder.cpp
AgeCommit message (Collapse)AuthorFilesLines
2020-01-09encoder: use contructor to initialize the vectorRomain Forlot1-5/+3
Instead of initilizing using a for loop... Also fixes a wrong watched bit using a bcm socket Change-Id: Ib65a3da06dbd249c97b8ec11823247120505d545 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2020-01-09decoder/encoder: typoRomain Forlot1-1/+1
Bug-AGL: SPEC-2991 Change-Id: I9ebea118770a9ffe0dd4321408643e76250e3635 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2020-01-09decoder/encoder: simplification of code.Romain Forlot1-80/+26
- Useless tests removed - Bit operation changed to more readable ones - Handle correctly mask to decode signal on 1 byte or in-between bytes more clearly. - using static_cast now instead of C casting method. - Avoid manual vector initialization and using default constructors instead. - Avoid using intermediate variables when this isn't necessary. Bug-AGL: SPEC-2988 Change-Id: I049d65f460109772b57df7572bdac8e6500242e0 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2020-01-09encoder: use switch case to handle CAN protocolsRomain Forlot1-31/+37
Better using switch case than if...else. This would be more extendable and readable. Bug-AGL: SPEC-2988 Change-Id: I5fb03531ad77441bcb7d1620bdb07d82aa6a4eb4 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2020-01-09All: Make format coherent with the whole projectRomain Forlot1-6/+6
Add a space after a comma Change some aligments Bug-AGL: SPEC-2988 Change-Id: I5069120f4bbb33742bb4990e2e1f391ec8d5eeb6 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2020-01-08all: Format one line 'if' or 'for' statement.Romain Forlot1-11/+6
Bug-AGL: SPEC-2988 Change-Id: Ic3b9670a2ce9e982220c54f3632f690ee4eea686 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2019-12-05Fix filter bitmask generationScott Murray1-1/+1
Fix filter bitmask generation in encoder_t::encode_data; the mask bits need to be left-aligned in each byte, not right-aligned. Bug-AGL: SPEC-3013 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: Ie084f81e3d8c06e69b5bb7562055187395099ac7
2019-08-30Replace all enum types with masksArthur Guyader1-3/+20
This commit allows to change all enum types by masks. Now to implement new protocol you don't need to add more attribute in class. All can be contained in the flags field. Bug-AGL : SPEC-2779 Change-Id: I814d0052139be5d5efefc9ff1b4b558f46b85e90 Signed-off-by: Arthur Guyader <arthur.guyader@iot.bzh>
2019-08-29Update function to encode and decode messageArthur Guyader1-83/+108
This commit update encoder and decoder files. This new implementation allows to manage larger signals. Bug-AGL : SPEC-2779 Change-Id: Iec6dfbd279863aa8b8e8f9e3ce951f0c8aa80dae Signed-off-by: Arthur Guyader <arthur.guyader@iot.bzh>
2019-08-12Add feature to build messages and fix some functionsArthur Guyader1-1/+113
Allows to build a message (J1939,BCM) with a signal and a value. Bug-AGL: SPEC-2386 Signed-off-by: Arthur Guyader <arthur.guyader@iot.bzh> Change-Id: Iadca13a927ff83f713f39da441c88356695a1285
2019-06-26Rename some of the classes removing can- prefixRomain Forlot1-8/+8
This commit renames files and classes : - can_message_definition_t -> message_definition_t - can_message_set_t -> message_set_t - can_signals_t -> signals_t This prepares the implementation of j1939 protocol. Bug-AGL: SPEC-2386 Change-Id: Ie3ee4f25c236c861b92eb12a56fa03a5a9afffbb Signed-off-by: Arthur Guyader <arthur.guyader@iot.bzh> Signed-off-by: Stephane Desneux <stephane.desneux@iot.bzh> Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-14CAN FD implementationRomain Forlot1-5/+6
Add a flag to CAN message definitions which set the message as using FD protocol if true. Use a new generated file with the new FD flag field on the message definitions. Change BCM socket "struct" using an union to store the CAN frames either using the FD struct or the classic non FD struct. A BCM socket can only one frame type once configured. Use as much as possible the "struct canfd_frame" in the binding and only make a difference before writing or reading the socket. From a memory point of view both struct are identical and only the last member differ and could hold more data with messages of 64 bytes long. So the canfd_frame is compatible with the can_frame and can be differentiated by a flag set in the can_id member. Remove now unused code processing can_frame. Keep the diagnostic manager using the classic CAN frame. Set the maximum number of frames that a BCM socket can handle to 257. Bug-AGL: SPEC-1980 Change-Id: Ifcc041281ea6745fc25cbd384743761f4446f489 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-11-22Code format and style changesRomain Forlot1-6/+6
Change-Id: Icfb7cdb53deba8d82b91f884c6b815adf0f17adf Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-05-24Fixing typos made in commentsydimitrov1-2/+2
This change set fixes the comments made by previous contributors v2: Fix line end v3: Making changes to comments as suggested by reviewers v4: Removing trailing spaces v5: Clearing small typo in low-can-cb.cpp on line 142 Change-Id: Ifbcfc3b2d131d1db0b25e472955b21e98cc09f45 Signed-off-by: ydimitrov <y.dimitrov.14@gmail.com>
2018-01-02Make low-can use afb-genskel by defaultRomain Forlot1-1/+0
Cleaning header file inclusion Change-Id: Ic0dd9637ecd491692bd4b8b39e9602e85498c0a9 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2017-11-30Correctly reconstituting entire CAN frameRomain Forlot1-5/+6
Change-Id: I39d226c6f6268ec880739e6b9230eb42ce475971 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2017-11-08Send entire CAN message rather than CAN signal.Romain Forlot1-7/+13
Old behavior send only the CAN signal, now we retrieve the CAN message value instead and send the CAN message with all CAN signals composing the message. Change-Id: I2394cc30630601e46aa939ddda88e8616372179e Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2017-07-21Fix: encoding value method has wrong signature.Romain Forlot1-6/+6
Change-Id: I227c721f782eef85f83db9ffdb7cc0e180d17da4 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2017-07-21Be able to write raw frame & encode value to sentRomain Forlot1-0/+159
Check whether the argument is a raw frame or a Signal + Value to encode then send. 1 new class to handle encoding part of a value as well as a new method for can_signal_t which return index of a map from its value. Change-Id: I288d2aeec28ce74c9ca35750db18557c9251e1df Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>