#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File #include "package.h" #include "RS485.h" #include "crc16.h" #include "cntrl_adr.h" #include "bios_dsp.h" #include "filter_bat2.h" #include "measure.h" #include "message.h" #include "ADC.h" #include "peripher.h" #include "ecan.h" #include "spise2p.h" #include "i2c.h" WORDE Modbus[ANSWER_LEN+1]; WORDE reply[REPLY_LEN]; unsigned int param[ANSWER_LEN+1]; LONGE* outputs; int DataAnalog1,DataAnalog2; ERROR * sens_error; int * sens_hi_edge; int * sens_lo_edge; unsigned int Maska[3][9]; void Default_params() { unsigned int i; for(i=0;iRS_Header[2] << 8) |*/ rs_arr->RS_Header[3]; // получили количество слов данных Length_MB = (rs_arr->RS_Header[4] << 8) | rs_arr->RS_Header[5]; ///////////////////////////////////////////////// // Отсылка /* Посчитали контрольную сумму перед самой посылкой */ rs_arr->buffer[0] = CNTRL_ADDR; rs_arr->buffer[1] = CMD_MODBUS_3; rs_arr->buffer[2] = Length_MB*2; for (i=0;ibuffer[3+i*2 ]=(Modbus[Address_MB+i].byt.byte_hi); rs_arr->buffer[3+i*2+1]=(Modbus[Address_MB+i].byt.byte_lo); } crc = 0xffff; crc = get_crc_16(crc, rs_arr->buffer, Length_MB*2+3); rs_arr->buffer[Length_MB*2+3] = LOBYTE(crc); rs_arr->buffer[Length_MB*2+4] = HIBYTE(crc); rs_arr->buffer[Length_MB*2+5] = 0; rs_arr->buffer[Length_MB*2+6] = 0; rs_arr->buffer[Length_MB*2+7] = 0; rs_arr->buffer[Length_MB*2+8] = 0; rs_arr->flag_TIMEOUT_to_Send=true; RS_Send(rs_arr, rs_arr->buffer, Length_MB*2+8); return; } void ReceiveCommandModbus6(RS_DATA *rs_arr) { unsigned int Address_MB, Data_MB, i; ///////////////////////////////////////////////// // Отсылка /* Отправлаем назад то же самое */ for (i=0;i<8;i++) rs_arr->buffer[i] = rs_arr->RS_Header[i]; // получили начальный адрес записи Address_MB = (/*(rs_arr->RS_Header[2] << 8) | */rs_arr->RS_Header[3]); // получили слово данных Data_MB = (rs_arr->RS_Header[4] << 8) | rs_arr->RS_Header[5]; Modbus[Address_MB].all = Data_MB; rs_arr->flag_TIMEOUT_to_Send=true; RS_Send(rs_arr, rs_arr->buffer, 10); }