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:
- 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.
- 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.
- 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.
- 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?