Razvalyaev
7e0063eee0
Все основные файлы подтянуты без изменений Изменены (только папка main_matlab): - заглушки для ненужных функций (main_matlab.c) - iq библиотека (IQmathLib_matlab.c) - библиотеки DSP281x
99 lines
2.9 KiB
C
99 lines
2.9 KiB
C
/*
|
|
* RS_Function_terminal.c
|
|
*
|
|
* Created on: 12 íîÿá. 2020 ã.
|
|
* 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 óêàçàòåëü íà ñòðóêòóðó ñòàíäàðòíîé êîìàíäû
|
|
CMD_TO_TMS_TEST_ALL_STRUCT* pcommand = (CMD_TO_TMS_TEST_ALL_STRUCT *)(RS232_Arr->RS_Header);
|
|
|
|
|
|
|
|
// íàñòðîèëè íà áóôåð ïðèåìà
|
|
// *(TMS_TO_TERMINAL_TEST_ALL_STRUCT*)RS232_Arr->buffer = reply_test_all; /* ?åîáõîäèìû ëåãêèå ïðèâåäåíèy */
|
|
|
|
|
|
// îòâåò, âûâîäèì äàííûå â òåðìèíàëêó
|
|
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; /* Íåîáõîäèìû ëåãêèå ïðèâåäåíèß */
|
|
|
|
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);
|
|
|
|
// -êîïèðóåì â áóôåð äëy âåðíîñòè
|
|
*(TMS_TO_TERMINAL_TEST_ALL_STRUCT*)RS232_Arr->buffer = reply_test_all; // ?åîáõîäèìû ëåãêèå ïðèâåäåíè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 óêàçàòåëü íà ñòðóêòóðó ñòàíäàðòíîé êîìàíäû
|
|
// íàñòðîèëè íà áóôåð ïðèåìà
|
|
//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);
|
|
// îòâåò, âûâîäèì äàííûå â òåðìèíàëêó
|
|
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; // Íåîáõîäèìû ëåãêèå ïðèâåäåíè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);
|
|
|
|
// Ñêîïèðóåì â áóôåð äëy âåðíîñòè
|
|
*(TMS_TO_TERMINAL_STRUCT*)RS232_Arr->buffer = reply; // Íåîáõîäèìû ëåãêèå ïðèâåäåíèy
|
|
RS_Send(RS232_Arr,RS232_Arr->buffer, sizeof(TMS_TO_TERMINAL_STRUCT)+1);
|
|
return;
|
|
}
|