finslib_init.cpp 820 B

12345678910111213141516171819202122232425
  1. #include "fins.h"
  2. /*
  3. * void XX_finslib_init_command( fins_command_tp *command, uint8_t snn, uint8_t cnn );
  4. *
  5. * 初始化FINS命令结构,该命令结构将用于包含要发送到远程PLC的命令。
  6. */
  7. void XX_finslib_init_command(struct fins_sys_tp *sys, struct fins_command_tp *command, uint8_t mrc, uint8_t src) {
  8. command->header[FINS_ICF] = 0x80;
  9. command->header[FINS_RSV] = 0x00;
  10. command->header[FINS_GCT] = 0x02;
  11. command->header[FINS_DNA] = sys->remote_net;
  12. command->header[FINS_DA1] = sys->remote_node;
  13. command->header[FINS_DA2] = sys->remote_unit;
  14. command->header[FINS_SNA] = sys->local_net;
  15. command->header[FINS_SA1] = sys->local_node;
  16. command->header[FINS_SA2] = sys->local_unit;
  17. command->header[FINS_SID] = sys->sid++;
  18. command->header[FINS_MRC] = mrc;
  19. command->header[FINS_SRC] = src;
  20. } /* XX_finslib_init_command */