5 Replies Latest reply on Dec 14, 2018 1:30 AM by ShanmathiN_06

    LIN Bus Conditional Publishing for Frame

    SaGr_3905476

      I've been working with a PSoC4 using PSoC Creator's LIN Slave Component. But I'm having trouble with conditional frame publishing. In my hardware setup, there is a single master and between 1-16 slave nodes. I programmed the firmware for the slave nodes to have automatic addressing support, so that each slave will have its own unique NAD (node address) to communicate with the master.

       

      When the slave subscribes to Frame A from the master, if it sees that the frame contains the NAD of that slave device, it needs to publish its data on the next Frame B that the master starts the header for. This way the master can publish Frame A with NAD 1, then it subscribes to Frame B and only gets data from the slave with NAD 1, and repeats for each slave. The master should get a SlaveNotResponding error for a Frame B if no slave exists that has the NAD that was specified in the previous Frame A.

       

      These are the things I've considered or tried so far:

      1. Using MRF (Master Request Frame) and SRF (Slave Response Frame), because the LIN Slave Component in PSoC Creator makes it easier to work with them. But unfortunately, the master's frames are already defined and in use by many other slave devices, so I cannot change the frames to use the MRF and SRF. I only control the firmware in each slave, so I'm stuck using the proprietary Frame A and Frame B method that was already defined.
      2. Adding Frame B into the LIN Slave Component with an Unconditional Publish. But then every slave device is responding to every Frame B, even if Frame A did not request their NAD to respond, so this is incorrect. The master requires not getting a response from a slave for Frame B if the previous Frame A's specified NAD does not exist, but that will not happen if each slave responds to every Frame B.
      3. I tried using the LIN Slave Component's function: ld_put_raw_LINS(txData) to send the data once from a slave after it sees its NAD in Frame A. However, the function's comment says "The data is sent in the next suitable frame (slave response frame)" but I can't use the SRF header, I need to use a custom Frame B header. I tried it anyways, and as expected it didn't work.
      4. I was looking at the slave changing Frame B's Publish / Subscribe direction, depending on if it should send data or not. For example, like this: "LINS_pidInfoTable[x][y] = (LINS_FRAME_DIR_PUBLISH | LINS_FRAME_DATA_SIZE_8 | LINS_FRAME_TYPE_UNCOND);" But this requires changes in the LIN Slave Component's automatically generated code, so my changes would be overwritten every time. It might work if I make a copy of the generated file, but it would be harder to maintain, so I'm hoping there's a better way.

       

      Is there something I'm missing for how to make a slave only publish a frame under certain conditions? Or is this just not currently supported by the LIN Slave Component and I need to write my own LIN interface?

        • 1. Re: LIN Bus Conditional Publishing for Frame
          ShanmathiN_06

          Hi,

           

          NAD is considered only during diagnostic frames. In case, you would want to use it for purposes other than diagnostics, you have to take care in the application layer, as the LIN spec is not defined for such use cases.

           

          For eg, you can read the data (NAD) sent from the master and decide whether a response has to be sent in the slave firmware.

          You could create a custom component as you could not modify the generated files (Please refer to component author guide by navigating to PSoC Creator-> Help-> Documentation).

          Else, if possible, you can also change the frame ID for each slave, to differentiate between the slaves (instead of relying on NAD).

           

          If there is no slave response frame, then you can generate a SlaveNotResponding error in the master firmware.

           

          I hope this helps!

          Thanks,
          Shanmathi

          • 2. Re: LIN Bus Conditional Publishing for Frame
            SaGr_3905476

            Hi Shanmathi,

             

            Thank you for your response.

             

            I understand that conditional publishing of a frame based on the NAD won't be automatically handled by the LIN spec and would require the application layer to take care of it. But I couldn't find anything in the LIN Slave Component's API that allows the application layer to achieve this degree of control. So I was curious if there's some functions I'm missing that are intended for this. The component automatically handles any frame marked as publish and I couldn't find a function providing a way to enable or disable a frame being published from the application layer.

             

            For changing the frame ID for each slave, it would be too burdensome to have separate versions of the firmware downloaded onto each of the 16 slaves, so there would have to be a way to dynamically change these frame IDs. The design is being done for a scenario where there would be many copies of the 1 master and 16 slaves. Do you know if there's a function in the LIN Slave Component that supports changing the frame ID as the firmware is running? So far as I can tell the component's auto-generated code sets all of the frame IDs to constants.

             

            Creating a custom component is possible, though I was hoping to avoid maintaining more custom software and modifying the existing LIN state machines if I could avoid it. But if this is the only way because the API doesn't support any other alternatives, then I won't have much of a choice.

             

            Best regards,

            Salt Gray

            • 3. Re: LIN Bus Conditional Publishing for Frame
              ShanmathiN_06

              Hi Salt Gray,

               

              We are extremely sorry to say that we do not have such provisions in our current LIN component.

              The only way is to write a custom component or create a LIN component using UART block.

               

              Thanks & Regards,
              Shanmathi

              • 4. Re: LIN Bus Conditional Publishing for Frame
                SaGr_3905476

                Hi Shanmathi,

                 

                Okay, thank you. That is unfortunate, but I'll be able to get around it after some work on my side.

                 

                For the moment, I've just disabled the automatic code generation for the PSOC components. Any time I need to make a change to the PSOC components, I'm re-enabling the code generation, then copying my custom changes back in to the LINS.c header file.

                 

                Best regards,

                Salt Gray

                • 5. Re: LIN Bus Conditional Publishing for Frame
                  ShanmathiN_06

                  Hi Salt Gray,

                   

                  I have created an enhancement request to include an API to change frame id and return NAD to application layer.

                   

                  Thanks,
                  Shanmathi