Lines Matching full:command
74 static int nos_device_read(const struct nos_device *dev, uint32_t command, in nos_device_read() argument
78 int err = dev->ops.read(dev->ctx, command, reinterpret_cast<uint8_t *>(buf), len); in nos_device_read()
96 static int nos_device_write(const struct nos_device *dev, uint32_t command, in nos_device_write() argument
100 int err = dev->ops.write(dev->ctx, command, reinterpret_cast<const uint8_t *>(buf), len); in nos_device_write()
118 * 2. Sending a command to the slave
124 * arguments and command message or the reply data.
239 // Calculate and set the CRC for the command from data or the struct
240 void SetCommandInfoCrc(const void* arg, uint16_t arg_len, uint32_t command, in SetCommandInfoCrc() argument
244 crc = crc16_update(&command, sizeof(command), crc); in SetCommandInfoCrc()
250 void SetCommandInfoCrc(const void* arg, uint16_t arg_len, uint32_t command, in SetCommandInfoCrc() argument
252 SetCommandInfoCrc(arg, arg_len, command, info, sizeof(*info)); in SetCommandInfoCrc()
258 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_READ | CMD_TRANSPORT; in TEST_F() local
259 ASSERT_EQ(nos_device_read(dev, command, &status, sizeof(transport_status)), 0); in TEST_F()
265 { // Send "go" command in TEST_F()
267 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_PARAM(0); in TEST_F() local
268 ASSERT_EQ(nos_device_write(dev, command, &command_info, sizeof(command_info)), 0); in TEST_F()
272 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_READ | CMD_TRANSPORT; in TEST_F() local
273 ASSERT_EQ(nos_device_read(dev, command, &status, sizeof(transport_status)), 0); in TEST_F()
279 { // Send "go" command in TEST_F()
283 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_PARAM(0); in TEST_F() local
284 ASSERT_EQ(nos_device_write(dev, command, &command_info, sizeof(command_info)), 0); in TEST_F()
286 // Let app process command in TEST_F()
290 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_READ | CMD_TRANSPORT; in TEST_F() local
291 ASSERT_EQ(nos_device_read(dev, command, &status, sizeof(transport_status)), 0); in TEST_F()
299 uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_DATA | CMD_TRANSPORT; in TEST_F() local
300 CMD_SET_PARAM(command, sizeof(data)); in TEST_F()
301 ASSERT_EQ(nos_device_write(dev, command, data, sizeof(data)), 0); in TEST_F()
303 { // Send "go" command in TEST_F()
306 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_PARAM(0); in TEST_F() local
307 ASSERT_EQ(nos_device_write(dev, command, &command_info, sizeof(command_info)), 0); in TEST_F()
311 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_READ | CMD_TRANSPORT; in TEST_F() local
312 ASSERT_EQ(nos_device_read(dev, command, &status, sizeof(transport_status)), 0); in TEST_F()
319 { // Send "go" command in TEST_F()
323 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_PARAM(TRANSPORT_TEST_HANG); in TEST_F() local
324 SetCommandInfoCrc(nullptr, 0, command, &command_info); in TEST_F()
325 ASSERT_EQ(nos_device_write(dev, command, &command_info, sizeof(command_info)), 0); in TEST_F()
329 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_READ | CMD_TRANSPORT; in TEST_F() local
330 ASSERT_EQ(nos_device_read(dev, command, &status, sizeof(transport_status)), 0); in TEST_F()
333 // Let app process command in TEST_F()
337 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_READ | CMD_TRANSPORT; in TEST_F() local
338 ASSERT_EQ(nos_device_read(dev, command, &status, sizeof(transport_status)), 0); in TEST_F()
341 // Let app process command in TEST_F()
345 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_READ | CMD_TRANSPORT; in TEST_F() local
346 ASSERT_EQ(nos_device_read(dev, command, &status, sizeof(transport_status)), 0); in TEST_F()
353 { // Send "go" command in TEST_F()
356 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_PARAM(TRANSPORT_TEST_HANG); in TEST_F() local
357 SetCommandInfoCrc(nullptr, 0, command, &command_info); in TEST_F()
358 ASSERT_EQ(nos_device_write(dev, command, &command_info, sizeof(command_info)), 0); in TEST_F()
361 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_TRANSPORT; in TEST_F() local
362 ASSERT_EQ(nos_device_write(dev, command, nullptr, 0), 0); in TEST_F()
366 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_READ | CMD_TRANSPORT; in TEST_F() local
367 ASSERT_EQ(nos_device_read(dev, command, &status, sizeof(transport_status)), 0); in TEST_F()
374 { // Send "go" command in TEST_F()
378 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_PARAM(TRANSPORT_TEST_HANG); in TEST_F() local
379 SetCommandInfoCrc(nullptr, 0, command, &command_info); in TEST_F()
380 ASSERT_EQ(nos_device_write(dev, command, &command_info, sizeof(command_info)), 0); in TEST_F()
382 { // Send "go" command in TEST_F()
386 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_PARAM(TRANSPORT_TEST_1234); in TEST_F() local
387 SetCommandInfoCrc(nullptr, 0, command, &command_info); in TEST_F()
388 ASSERT_EQ(nos_device_write(dev, command, &command_info, sizeof(command_info)), 0); in TEST_F()
390 // Let app process command in TEST_F()
395 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_READ | CMD_TRANSPORT; in TEST_F() local
396 ASSERT_EQ(nos_device_read(dev, command, &status, sizeof(transport_status)), 0); in TEST_F()
402 { // Send "go" command in TEST_F()
406 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_PARAM(TRANSPORT_TEST_NOP); in TEST_F() local
407 SetCommandInfoCrc(nullptr, 0, command, &command_info); in TEST_F()
408 ASSERT_EQ(nos_device_write(dev, command, &command_info, sizeof(command_info)), 0); in TEST_F()
410 // Let app process command in TEST_F()
414 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_READ | CMD_TRANSPORT; in TEST_F() local
415 ASSERT_EQ(nos_device_read(dev, command, &status, sizeof(transport_status)), 0); in TEST_F()
422 { // Send "go" command in TEST_F()
427 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_PARAM(TRANSPORT_TEST_1234); in TEST_F() local
428 SetCommandInfoCrc(nullptr, 0, command, &command_info); in TEST_F()
429 ASSERT_EQ(nos_device_write(dev, command, &command_info, sizeof(command_info)), 0); in TEST_F()
431 // Let app process command in TEST_F()
435 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_READ | CMD_TRANSPORT; in TEST_F() local
436 ASSERT_EQ(nos_device_read(dev, command, &status, sizeof(transport_status)), 0); in TEST_F()
449 { // Send "go" command in TEST_F()
454 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_PARAM(TRANSPORT_TEST_1234); in TEST_F() local
455 SetCommandInfoCrc(nullptr, 0, command, &command_info); in TEST_F()
456 ASSERT_EQ(nos_device_write(dev, command, &command_info, sizeof(command_info)), 0); in TEST_F()
458 // Let app process command in TEST_F()
463 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_READ | CMD_TRANSPORT; in TEST_F() local
464 ASSERT_EQ(nos_device_read(dev, command, &status, sizeof(transport_status)), 0); in TEST_F()
478 { // Send "go" command in TEST_F()
483 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_PARAM(TRANSPORT_TEST_1234); in TEST_F() local
484 SetCommandInfoCrc(nullptr, 0, command, &command_info); in TEST_F()
485 ASSERT_EQ(nos_device_write(dev, command, &command_info, sizeof(command_info)), 0); in TEST_F()
487 // Let app process command in TEST_F()
491 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_READ | CMD_TRANSPORT; in TEST_F() local
492 ASSERT_EQ(nos_device_read(dev, command, &status, sizeof(transport_status)), 0); in TEST_F()
506 { // Send "go" command in TEST_F()
510 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_PARAM(TRANSPORT_TEST_NOP); in TEST_F() local
511 SetCommandInfoCrc(nullptr, 0, command, &command_info); in TEST_F()
512 ASSERT_EQ(nos_device_write(dev, command, &command_info, sizeof(command_info)), 0); in TEST_F()
514 // Let app process command in TEST_F()
517 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_TRANSPORT; in TEST_F() local
518 ASSERT_EQ(nos_device_write(dev, command, nullptr, 0), 0); in TEST_F()
522 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_READ | CMD_TRANSPORT; in TEST_F() local
523 ASSERT_EQ(nos_device_read(dev, command, &status, sizeof(transport_status)), 0); in TEST_F()
529 { // Send "go" command in TEST_F()
533 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_PARAM(0); in TEST_F() local
534 ASSERT_EQ(nos_device_write(dev, command, &command_info, sizeof(command_info)), 0); in TEST_F()
536 // Let app process command in TEST_F()
539 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_TRANSPORT; in TEST_F() local
540 ASSERT_EQ(nos_device_write(dev, command, nullptr, 0), 0); in TEST_F()
544 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_READ | CMD_TRANSPORT; in TEST_F() local
545 ASSERT_EQ(nos_device_read(dev, command, &status, sizeof(transport_status)), 0); in TEST_F()
553 uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_DATA | CMD_TRANSPORT; in TEST_F() local
554 CMD_SET_PARAM(command, sizeof(data)); in TEST_F()
555 ASSERT_EQ(nos_device_write(dev, command, &data, sizeof(data)), 0); in TEST_F()
557 { // Send "go" command in TEST_F()
561 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_PARAM(TRANSPORT_TEST_9876); in TEST_F() local
562 SetCommandInfoCrc(&data, sizeof(data), command, &command_info); in TEST_F()
563 ASSERT_EQ(nos_device_write(dev, command, &command_info, sizeof(command_info)), 0); in TEST_F()
565 // Let app process command in TEST_F()
569 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_READ | CMD_TRANSPORT; in TEST_F() local
570 ASSERT_EQ(nos_device_read(dev, command, &status, sizeof(transport_status)), 0); in TEST_F()
580 uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_DATA | CMD_TRANSPORT; in TEST_F() local
581 CMD_SET_PARAM(command, sizeof(data1)); in TEST_F()
582 ASSERT_EQ(nos_device_write(dev, command, &data1, sizeof(data1)), 0); in TEST_F()
586 uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) in TEST_F() local
588 CMD_SET_PARAM(command, sizeof(data2)); in TEST_F()
589 ASSERT_EQ(nos_device_write(dev, command, &data2, sizeof(data2)), 0); in TEST_F()
591 { // Send "go" command in TEST_F()
595 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_PARAM(TRANSPORT_TEST_9876); in TEST_F() local
596 SetCommandInfoCrc(&data, sizeof(data), command, &command_info); in TEST_F()
597 ASSERT_EQ(nos_device_write(dev, command, &command_info, sizeof(command_info)), 0); in TEST_F()
599 // Let app process command in TEST_F()
603 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_READ | CMD_TRANSPORT; in TEST_F() local
604 ASSERT_EQ(nos_device_read(dev, command, &status, sizeof(transport_status)), 0); in TEST_F()
614 uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_DATA | CMD_TRANSPORT; in TEST_F() local
615 CMD_SET_PARAM(command, sizeof(data1)); in TEST_F()
616 ASSERT_EQ(nos_device_write(dev, command, &data1, sizeof(data1)), 0); in TEST_F()
620 uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_DATA | CMD_TRANSPORT; in TEST_F() local
621 CMD_SET_PARAM(command, sizeof(data2)); in TEST_F()
622 ASSERT_EQ(nos_device_write(dev, command, &data2, sizeof(data2)), 0); in TEST_F()
624 { // Send "go" command in TEST_F()
628 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_PARAM(TRANSPORT_TEST_9876); in TEST_F() local
629 SetCommandInfoCrc(&data, sizeof(data), command, &command_info); in TEST_F()
630 ASSERT_EQ(nos_device_write(dev, command, &command_info, sizeof(command_info)), 0); in TEST_F()
632 // Let app process command in TEST_F()
636 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_READ | CMD_TRANSPORT; in TEST_F() local
637 ASSERT_EQ(nos_device_read(dev, command, &status, sizeof(transport_status)), 0); in TEST_F()
647 uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_DATA | CMD_TRANSPORT; in TEST_F() local
648 CMD_SET_PARAM(command, sizeof(spam)); in TEST_F()
649 ASSERT_EQ(nos_device_write(dev, command, spam, sizeof(spam)), 0); in TEST_F()
653 uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_DATA | CMD_TRANSPORT; in TEST_F() local
654 CMD_SET_PARAM(command, sizeof(data1)); in TEST_F()
655 ASSERT_EQ(nos_device_write(dev, command, &data1, sizeof(data1)), 0); in TEST_F()
659 uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) in TEST_F() local
661 CMD_SET_PARAM(command, sizeof(data2)); in TEST_F()
662 ASSERT_EQ(nos_device_write(dev, command, &data2, sizeof(data2)), 0); in TEST_F()
664 { // Send "go" command in TEST_F()
668 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_PARAM(TRANSPORT_TEST_9876); in TEST_F() local
669 SetCommandInfoCrc(&data, sizeof(data), command, &command_info); in TEST_F()
670 ASSERT_EQ(nos_device_write(dev, command, &command_info, sizeof(command_info)), 0); in TEST_F()
672 // Let app process command in TEST_F()
676 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_READ | CMD_TRANSPORT; in TEST_F() local
677 ASSERT_EQ(nos_device_read(dev, command, &status, sizeof(transport_status)), 0); in TEST_F()
684 /* New command info fields may be add in future versions. The crc is still
688 { // Send "go" command in TEST_F()
696 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_PARAM(TRANSPORT_TEST_NOP); in TEST_F() local
698 SetCommandInfoCrc(nullptr, 0, command, &command_info, sizeof(command_info)); in TEST_F()
699 ASSERT_EQ(nos_device_write(dev, command, &command_info, sizeof(command_info)), 0); in TEST_F()
701 // Let app process command in TEST_F()
705 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_READ | CMD_TRANSPORT; in TEST_F() local
706 ASSERT_EQ(nos_device_read(dev, command, &status, sizeof(transport_status)), 0); in TEST_F()
711 /* If the protocol adds more data to the command info datagram, it is not
714 { // Send "go" command in TEST_F()
722 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_PARAM(0); in TEST_F() local
723 SetCommandInfoCrc(nullptr, 0, command, &command_info, sizeof(command_info)); in TEST_F()
724 ASSERT_EQ(nos_device_write(dev, command, &command_info, sizeof(command_info)), 0); in TEST_F()
726 // Let app process command in TEST_F()
730 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_READ | CMD_TRANSPORT; in TEST_F() local
731 ASSERT_EQ(nos_device_read(dev, command, &status, sizeof(transport_status)), 0); in TEST_F()
736 /* Future protocol updates may require more command info data which will be
738 * command info struct. The extra data should be ignored to allow for
741 { // Send "go" command in TEST_F()
753 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_PARAM(TRANSPORT_TEST_NOP); in TEST_F() local
755 SetCommandInfoCrc(nullptr, 0, command, &command_info, sizeof(command_info)); in TEST_F()
756 ASSERT_EQ(nos_device_write(dev, command, &command_info, sizeof(command_info)), 0); in TEST_F()
758 // Let app process command in TEST_F()
762 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_READ | CMD_TRANSPORT; in TEST_F() local
763 ASSERT_EQ(nos_device_read(dev, command, &status, sizeof(transport_status)), 0); in TEST_F()
770 /* V0 does not send any checksums or command info */
774 uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_DATA | CMD_TRANSPORT; in TEST_F() local
775 CMD_SET_PARAM(command, sizeof(data)); in TEST_F()
776 ASSERT_EQ(nos_device_write(dev, command, &data, sizeof(data)), 0); in TEST_F()
780 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_READ | CMD_TRANSPORT; in TEST_F() local
781 ASSERT_EQ(nos_device_read(dev, command, &status, sizeof(transport_status)), 0); in TEST_F()
784 { // Send "go" command (without command info or crc) in TEST_F()
785 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_PARAM(TRANSPORT_TEST_NOP); in TEST_F() local
786 ASSERT_EQ(nos_device_write(dev, command, nullptr, 0), 0); in TEST_F()
788 // Let app process command in TEST_F()
792 const uint32_t command = CMD_ID(APP_ID_TRANSPORT_TEST) | CMD_IS_READ | CMD_TRANSPORT; in TEST_F() local
793 ASSERT_EQ(nos_device_read(dev, command, &status, sizeof(transport_status)), 0); in TEST_F()