dialysate_delivery.py

Clone Tools
  • last updated a few minutes ago
Constraints
Constraints: committers
 
Constraints: files
Constraints: dates
The approach of what this code does and the conversion module are similar in function but a differ on maintenance and flexibility. 1. The conversion module's bytearray to value methods work, but th...

The approach of what this code does and the conversion module are similar in function but a differ on maintenance and flexibility.
1. The conversion module's bytearray to value methods work, but they require manual logistic around the indexing. It's the user's responsibility to handle where the reading starts and you need to code the handler for that (previous approach with MsgFieldPositions), It's inflating the method. I worked hard to remove the need for indexing where the value starts. Instead of the previous struct.unpack approach, where you needed to maintain the type, you will be needing to maintain the conversion methods that are being called, so it would be the same as before, you still need to mind the indexing, which was the main reason of changing from this approach.

2. In the current approach, you declare the type and pass it to a processor that dynamically handling the unpack type (based on the set datatype) and the indexing for that. This works much better and easier to maintain, as you can just insert a new value when it's added to the FW, and don't need to adjust all your indexes for the reading.

Example #1, changing build type from U16 to U08:

  • with the conversion approach, you need to change the function used, and update the starting index for all the following methods.
  • with the current approach you change the Datatype.U16 to Datatype.U08 and that's all you need to do.


Example #2: adding a new variable fpga_micro after fpga_minor, with U08 type:

  • with the conversion approach, you add the bytearray_to_byte, update the indexes for all the following reads.
  • with the current approach you insert an element after the fpga_minor with a value ('fpga_micro', Datatype.U08), and nothing more needed
RESOLVED for now.

RESOLVED for now.

I would not do that because the function names and messages for each project should be different to avoid confusion. I think that is fine for now. RESOLVED.

I would not do that because the function names and messages for each project should be different to avoid confusion.
I think that is fine for now.

RESOLVED.

So the same channels are used for both the Leahi and Denali? I am not talking about how collisions are handled; that is handled by the CAN driver, not the FW or SW. My point is that the CAN Channel...

So the same channels are used for both the Leahi and Denali?
I am not talking about how collisions are handled; that is handled by the CAN driver, not the FW or SW.
My point is that the CAN Channels by themselves do not have the meaning we want; they are only a priority.
As we defined them, we gave them a meaning as a category; therefore, it is better to name them the Denali/Leahi Channels rather than the CAN Channels.

RESOLVED.

RESOLVED.

def fp_versions(self, major: int, minor: int, micro: int, build: int, fpga_id: int, fpga_major: int, fpga_minor: int, fpga_lab: int, compatibility_rev: int...
def fp_versions(self, major: int, minor: int, micro: int, build: int,
                     fpga_id: int, fpga_major: int, fpga_minor: int, fpga_lab: int,
                     compatibility_rev: int):
     """
     Broadcasts the current dd Version Data (Msg ID: 0x0F, 15)
     Args:
         @param major: (uint) - Major version number
         @param minor: (uint) - Minor version number
         @param micro: (uint) - Micro version number
         @param build: (uint) - Build version number
         @param fpga_id: (int) - FPGA id version number
         @param fpga_major: (int) - FPGA Major version number
         @param fpga_minor: (int) - FPGA Minor version number
         @param fpga_lab: (int) - FPGA Lab version number
         @param compatibility_rev: (uint) - The FWs/UI compatibility revision
     @return: None
     """
     if not self.can_enabled:
         raise ValueError("CAN Interface is not enabled")

     payload =  conversions.unsigned_byte_to_bytearray   (major            )
     payload += conversions.unsigned_byte_to_bytearray   (minor            )
     payload += conversions.unsigned_byte_to_bytearray   (micro            )
     payload += conversions.unsigned_short_to_bytearray  (build            )
     payload += conversions.unsigned_byte_to_bytearray   (fpga_id          )
     payload += conversions.unsigned_byte_to_bytearray   (fpga_major       )
     payload += conversions.unsigned_byte_to_bytearray   (fpga_minor       )
     payload += conversions.unsigned_byte_to_bytearray   (fpga_lab         )
     payload += conversions.unsigned_integer_to_bytearray(compatibility_rev)

     message = CAN.CanMessage.build_message(
                                         channel_id=CAN.CanChannels.fp_sync_broadcast_ch_id,
                                         message_id=msg_ids.MsgIds.MSG_ID_FP_VERSION_RESPONSE.value,
                                         payload=payload)

     self.can_interface.send(message, 0)
Being generic is the whole point of it. It was renamed because this is a dialin dedicated to Leahi unit and calling the messages DenaliMessage is misleading. It was renamed to CanMessage for 2 reas...

Being generic is the whole point of it.
It was renamed because this is a dialin dedicated to Leahi unit and calling the messages DenaliMessage is misleading.
It was renamed to CanMessage for 2 reason:
1. This is a Leahi only dialin, so there is no need to differentiate between different type of Can Messages as there would be only 1 type
2. Calling it CanMessage will make it more future compatible when the dialin get copied over for a new unit development (unlikely in the foreseeable future but possible), removing the need to rename it again

There is no Leahi or Denali CANChannels. There are CAN channels and the naming is what that channel is being used for. The collision occurs in the FW and the FW handles it before sending out a mess...

There is no Leahi or Denali CANChannels.
There are CAN channels and the naming is what that channel is being used for.
The collision occurs in the FW and the FW handles it before sending out a message.
When reading a CAN, there are no collisions, so there are no priorities. So I have no clue what you want here.

done

done

I have no idea what you are referring to as the link is not working. The need to define the type and the name of the data being read is necessary, so if it's not here it will be somewhere else, tha...

I have no idea what you are referring to as the link is not working.
The need to define the type and the name of the data being read is necessary, so if it's not here it will be somewhere else, that we can't escape.
Exporting that to different files won't serve a purpose and will only increase complexity as when debugging you will need to reference a separate file.
For the defs it made sense as they are used multiple places, but what a message contains is a single use place, so storing it separately is meaningless as it won't have any use outside of this single function.

I am happy to see that this old code is improving. I would recommend using the Conversion module instead of strings and DataTypes, as it handles everything automatically. Examples can be found in t...

I am happy to see that this old code is improving.
I would recommend using the Conversion module instead of strings and DataTypes, as it handles everything automatically.
Examples can be found in the following file in this CR:
https://devapps.diality.us/cru/#LEAHI-DIALIN-LDT-4484-1CFR-84688

Please add a docstring for the function. including the intention and parameters with their intentions.

Please add a docstring for the function.
including the intention and parameters with their intentions.

Same for CanChannels. The Channels we are referring to here are Leahi's or Denali's. Channels mainly have no meaning beyond their priorities when a collision occurs.

Same for CanChannels.
The Channels we are referring to here are Leahi's or Denali's.
Channels mainly have no meaning beyond their priorities when a collision occurs.

I recommend DenaliMessage or LeahiMessage, as CanMessage is generic, whereas Leahi/Denali indicate that the protocol is also implemented in the message we are sending. I'm not sure why the name was...

I recommend DenaliMessage or LeahiMessage, as CanMessage is generic, whereas Leahi/Denali indicate that the protocol is also implemented in the message we are sending.
I'm not sure why the name was changed, as it is a lot of change.
Also, there is no CAN Message.
There is a CAN Frame and a Leahi/Denali Message.

updated

updated

Remove extra spaces before comment

Remove extra spaces before comment

Please consult the FW-SW integration xls file for MSG_ID reservations. Please add the ones you need to that list as without missing any reservations for IDs the randomly added IDs will be overwritt...

Please consult the FW-SW integration xls file for MSG_ID reservations.
Please add the ones you need to that list as without missing any reservations for IDs the randomly added IDs will be overwritten by reserved ones.

Instead of removing, could you move them to the bottom of the list to prevent exceptions being thrown?

Instead of removing, could you move them to the bottom of the list to prevent exceptions being thrown?

LEAHI-DIALIN-LDT-4732_(Dialin) Dialin version should be included in the all system logs
LEAHI-DIALIN-LDT-4732_(Dialin) Dialin version should be included in the all system logs
Updated msg IDs Updated version handling

  1. … 3 more files in changeset.
Rename to CanChannels

Rename to CanChannels

Rename to CanChannels

Rename to CanChannels

Let it be there. Because of this, i could not complete the 30+ data broadcast.

Let it be there. Because of this, i could not complete the 30+ data broadcast.

align the indent or remove blank space before =

align the indent or remove blank space before =

remove blank space before =

remove blank space before =