Skip to main content
Version: 3.1.0

phy's APIs

By writing phy code you will have the opportunity to use the Luos engine's APIs. These APIs are designed to help you to manage your messages receptions an transmission to the Luos engine.

Because there is a lot of different ways to receive and send messages trough networks, you will also have the possibility to use some luos_phy_t values to interact with the Luos engine depending on the strategy you choose.

Phy basic creation functions

DescriptionFunctionReturn
Declare your phy to Luos engine and provide all the needed callbacksPhy_Create(JOB_CB job_cb, RUN_TOPO run_topo, RESET_PHY reset_phy);luos_phy_t *
This callback will be called by Luos engine when a job is allocated to this phy(*JOB_CB)(luos_phy_t *phy_ptr, phy_job_t *job);void
This callback will be called by Luos engine when a topology detection need to be done(*RUN_TOPO)(luos_phy_t *phy_ptr, uint8_t *portId);error_return_t
This callback will be called by Luos engine when the system is reseted (mostly at detection start)(*RESET_PHY)(luos_phy_t *phy_ptr);void

Phy IRQ management functions

DescriptionFunctionReturn
Use this function to reference an optional IRQ_STATE manager to Luos ()Phy_SetIrqStateFunciton(IRQ_STATE irq_state);void
This callback will be called by Luos engine when your phy IRQ needs to be disabled or enabled(*IRQ_STATE)(bool state);void
This funciton allow you to enable or disable IRQs of all the other physPhy_SetIrqState(bool state);void

Phy topology management functions

DescriptionFunctionReturn
You have to call this function if you receive a topology detection request from another nodePhy_TopologySource(luos_phy_t *phy_ptr, uint8_t port_id);void
After a port detection, if you have other ports that need to be detect, ask phy about it.Phy_TopologyNext(void);void
After a port detection, if you don't have other ports that need to be detect, tell phy you are done.Phy_TopologyDone(luos_phy_t *phy_ptr);void

Phy jobs management functions

DescriptionFunctionReturn
Use this fucntion to get the next job containing the message to send.Phy_GetJob(luos_phy_t *phy_ptr);phy_job_t *
When a job is done, you have to tell phy to remove it.Phy_RmJob(luos_phy_t *phy_ptr, phy_job_t *job);void
When a job transmission failed, you have to tell phy about it.Phy_FailedJob(luos_phy_t *phy_ptr, phy_job_t *job);void
When a job transmission failed, you have to tell phy about it.Phy_GetJobNumber(luos_phy_t *phy_ptr);uint16_t

Phy transmission management functions

DescriptionFunctionReturn
When you need to transmit a timestamped message, use this to get the timestamp value to sendPhy_ComputeMsgTimestamp(phy_job_t *job);time_luos_t
Use it to get your current node id. (This can be used to compute priority or controled latency avoiding infinite collision condition)Phy_GetNodeId(void);uint16_t

Phy reception management functions

DescriptionFunctionReturn
After receiving the first 7 bytes (the header) call this function to compute how you should manage the incoming message.Phy_ComputeHeader(luos_phy_t *phy_ptr);void
After receiving as much valid bytes as phy_ptr.rx_size, call this function to validate the message.Phy_ValidMsg(luos_phy_t *phy_ptr);void
After receiving as much valid bytes as phy_ptr.rx_size, call this function to validate the message.Phy_ResetMsg(luos_phy_t *phy_ptr);void
When you receive a message you have to save the reception timetamp, use this function to get it. Watch out this value is an integer in nanosecondsPhy_GetTimestamp(void);uint64_t

luos_phy_t structure public fields

DirectionDescriptionFieldtype
WriteWhen you receive a message save the timestamp of the first received byte. You may need to compute the bytes transmission time to get the exact value.rx_timestamptime_luos_t
WriteYour phy base RX msg buffer pointer.rx_buffer_baseuint8_t *
WriteYour phy curent RX byte pointer in the RX msg buffer. Each received byte will be written in this pointer then the pointer will be increased.rx_datauint8_t *
WriteThe number of received byte in this message.received_datauint16_t
ReadThe number of bytes needed for this message to be complete.rx_sizeuint16_t
ReadTrue if you should keep this message, False if not.rx_keepbool
ReadTrue if you should acknoledge this message, False if not.rx_ackbool