matlab_23550/Inu/Src/N12_Xilinx/RS_Function_terminal.c

99 lines
2.9 KiB
C
Raw Normal View History

/*
* RS_Function_terminal.c
*
* Created on: 12 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>. 2020 <EFBFBD>.
* Author: stud
*/
#include "RS_Function_terminal.h"
#include <message2.h>
#include <message2test.h>
#include "modbus_table_v2.h"
#include "options_table.h"
#include "DSP281x_Device.h"
#include "CRC_Functions.h"
#include "MemoryFunctions.h"
#include "RS_Functions.h"
#pragma DATA_SECTION(reply, ".slow_vars")
TMS_TO_TERMINAL_STRUCT reply = TMS_TO_TERMINAL_STRUCT_DEFAULT;
#pragma DATA_SECTION(reply_test_all, ".slow_vars")
TMS_TO_TERMINAL_TEST_ALL_STRUCT reply_test_all = TMS_TO_TERMINAL_TEST_ALL_STRUCT_DEFAULT;
void ReceiveCommandTestAll(RS_DATA_STRUCT *RS232_Arr)
{
unsigned int crc;
// int Data,Data1,Data2,Data3, Data4, DataM, tk1,tk2,tk3,tk0,period = 0, periodMiddle = 0, DataAnalog1, DataAnalog2, doubleImpulse, sinusImpulse;
// static unsigned int prevImp;
// const <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CMD_TO_TMS_TEST_ALL_STRUCT* pcommand = (CMD_TO_TMS_TEST_ALL_STRUCT *)(RS232_Arr->RS_Header);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// *(TMS_TO_TERMINAL_TEST_ALL_STRUCT*)RS232_Arr->buffer = reply_test_all; /* ?<3F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>y */
// <20><><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
reply_test_all.head.Address = RS232_Arr->addr_recive;//CNTRL_ADDR;
reply_test_all.head.Number = CMD_RS232_TEST_ALL;
func_fill_answer_to_TMS_test(&reply_test_all, pcommand);
*(TMS_TO_TERMINAL_TEST_ALL_STRUCT*)RS232_Arr->buffer = reply_test_all; /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
crc = 0xffff;
crc = GetCRC16_IBM( crc, RS232_Arr->buffer, sizeof(TMS_TO_TERMINAL_TEST_ALL_STRUCT)-3);
reply_test_all.crc_lo = LOBYTE(crc);
reply_test_all.crc_hi = HIBYTE(crc);
// -<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><>y <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*(TMS_TO_TERMINAL_TEST_ALL_STRUCT*)RS232_Arr->buffer = reply_test_all; // ?<3F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>y
RS_Send(RS232_Arr,RS232_Arr->buffer, sizeof(TMS_TO_TERMINAL_TEST_ALL_STRUCT)+1);
return;
}
void ReceiveCommand(RS_DATA_STRUCT *RS232_Arr)
{
unsigned int crc;
// const <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//CMD_TO_TMS* const pcommand = (CMD_TO_TMS *)(RS232_Arr->RS_Header);
CMD_TO_TMS_STRUCT* pcommand = (CMD_TO_TMS_STRUCT *)(RS232_Arr->RS_Header);
// <20><><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
reply.head.Address = RS232_Arr->addr_recive;//CNTRL_ADDR;
reply.head.Number = CMD_RS232_STD;
// func_fill_answer_to_TMS(&reply, pcommand);
func_unpack_answer_from_TMS_RS232(pcommand);
func_pack_answer_to_TMS(&reply);
*(TMS_TO_TERMINAL_STRUCT*)RS232_Arr->buffer = reply; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>y
crc = 0xffff;
crc = GetCRC16_IBM( crc, RS232_Arr->buffer, sizeof(TMS_TO_TERMINAL_STRUCT)-3);
reply.crc_lo = LOBYTE(crc);
reply.crc_hi = HIBYTE(crc);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><>y <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
*(TMS_TO_TERMINAL_STRUCT*)RS232_Arr->buffer = reply; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>y
RS_Send(RS232_Arr,RS232_Arr->buffer, sizeof(TMS_TO_TERMINAL_STRUCT)+1);
return;
}