* Custom functions for read/write OD object _OD_statusBits_, optional * * For more information see file CO_ODinterface.h, OD_IO_t. */
| 156 | * For more information see file CO_ODinterface.h, OD_IO_t. |
| 157 | */ |
| 158 | static ODR_t |
| 159 | OD_read_1003(OD_stream_t* stream, void* buf, OD_size_t count, OD_size_t* countRead) { |
| 160 | if ((stream == NULL) || (buf == NULL) || (countRead == NULL) || ((count < 4U) && (stream->subIndex > 0U)) |
| 161 | || (count < 1U)) { |
| 162 | return ODR_DEV_INCOMPAT; |
| 163 | } |
| 164 | |
| 165 | CO_EM_t* em = (CO_EM_t*)stream->object; |
| 166 | |
| 167 | if (em->fifoSize < 2U) { |
| 168 | return ODR_DEV_INCOMPAT; |
| 169 | } |
| 170 | if (stream->subIndex == 0U) { |
| 171 | (void)CO_setUint8(buf, em->fifoCount); |
| 172 | |
| 173 | *countRead = sizeof(uint8_t); |
| 174 | return ODR_OK; |
| 175 | } else if (stream->subIndex <= em->fifoCount) { |
| 176 | /* newest error is reported on subIndex 1 and is stored just behind |
| 177 | * fifoWrPtr. Get correct index in FIFO buffer. */ |
| 178 | int16_t index = (int16_t)em->fifoWrPtr - (int16_t)stream->subIndex; |
| 179 | if (index < 0) { |
| 180 | index += (int16_t)em->fifoSize; |
| 181 | } else if (index >= (int16_t)(em->fifoSize)) { |
| 182 | return ODR_DEV_INCOMPAT; |
| 183 | } else { /* MISRA C 2004 14.10 */ |
| 184 | } |
| 185 | (void)CO_setUint32(buf, em->fifo[index].msg); |
| 186 | |
| 187 | *countRead = sizeof(uint32_t); |
| 188 | return ODR_OK; |
| 189 | } else { |
| 190 | return ODR_NO_DATA; |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | static ODR_t |
| 195 | OD_write_1003(OD_stream_t* stream, const void* buf, OD_size_t count, OD_size_t* countWritten) { |
nothing calls this directly
no test coverage detected