Mercurial > public > ostc4
comparison Discovery/Src/data_exchange_main.c @ 275:189387bf23a8 IPC_Sync_Improvment_3
Do not mark data as valid if devicedata is received.
The variable lost_connection_to_slave is used to identify if data may be copied from the com buffer to the lifedata structure. In case devicedata was received the data in the lifedata may be invalid and therefor should not be copied
author | ideenmodellierer |
---|---|
date | Sun, 28 Apr 2019 09:54:43 +0200 |
parents | f0069f002c55 |
children | cc30d1aa03a7 |
comparison
equal
deleted
inserted
replaced
267:cf6ad20380fb | 275:189387bf23a8 |
---|---|
777 DataEX_copy_to_DeviceData(); | 777 DataEX_copy_to_DeviceData(); |
778 DataEX_merge_DeviceData_and_store(); | 778 DataEX_merge_DeviceData_and_store(); |
779 DataEX_copy_to_VpmRepetitiveData(); | 779 DataEX_copy_to_VpmRepetitiveData(); |
780 data_old__lost_connection_to_slave_counter_temp = 0; | 780 data_old__lost_connection_to_slave_counter_temp = 0; |
781 data_old__lost_connection_to_slave_counter_retry = 0; | 781 data_old__lost_connection_to_slave_counter_retry = 0; |
782 pStateReal->data_old__lost_connection_to_slave = 0; | 782 /* Do not yet reset state. Wait till common data has been received in next cycle. Otherwise invalid data may be forwarded for processing */ |
783 /* pStateReal->data_old__lost_connection_to_slave = 0; */ | |
783 dataOut.header.checkCode[SPI_HEADER_INDEX_RX_STATE] = SPI_RX_STATE_OK; | 784 dataOut.header.checkCode[SPI_HEADER_INDEX_RX_STATE] = SPI_RX_STATE_OK; |
784 } | 785 } |
785 else | 786 else |
786 { | 787 { |
787 pStateReal->data_old__lost_connection_to_slave = 1; | 788 pStateReal->data_old__lost_connection_to_slave = 1; |
964 /* battery and ambient light sensors | 965 /* battery and ambient light sensors |
965 */ | 966 */ |
966 pStateReal->lifeData.ambient_light_level = dataIn.data[dataIn.boolAmbientLightData].ambient_light_level; | 967 pStateReal->lifeData.ambient_light_level = dataIn.data[dataIn.boolAmbientLightData].ambient_light_level; |
967 pStateReal->lifeData.battery_charge = dataIn.data[dataIn.boolBatteryData].battery_charge; | 968 pStateReal->lifeData.battery_charge = dataIn.data[dataIn.boolBatteryData].battery_charge; |
968 pStateReal->lifeData.battery_voltage = dataIn.data[dataIn.boolBatteryData].battery_voltage; | 969 pStateReal->lifeData.battery_voltage = dataIn.data[dataIn.boolBatteryData].battery_voltage; |
970 | |
971 /* PIC data | |
972 */ | |
973 for(int i=0;i<4;i++) | |
974 { | |
975 pStateReal->lifeData.buttonPICdata[i] = dataIn.data[dataIn.boolPICdata].button_setting[i]; | |
976 } | |
977 | |
978 /* sensorErrors | |
979 */ | |
980 pStateReal->sensorErrorsRTE = dataIn.sensorErrors; | |
969 } | 981 } |
970 | 982 |
971 /* apnea specials | 983 /* apnea specials |
972 */ | 984 */ |
973 if(pStateReal->diveSettings.diveMode == DIVEMODE_Apnea) | 985 if(pStateReal->diveSettings.diveMode == DIVEMODE_Apnea) |
1038 { | 1050 { |
1039 pStateReal->lifeData.internal.stopwatch_start_at_this_dive_time_seconds = pStateReal->lifeData.dive_time_seconds; | 1051 pStateReal->lifeData.internal.stopwatch_start_at_this_dive_time_seconds = pStateReal->lifeData.dive_time_seconds; |
1040 pStateReal->lifeData.boolResetStopwatch = 0; | 1052 pStateReal->lifeData.boolResetStopwatch = 0; |
1041 } | 1053 } |
1042 pStateReal->lifeData.stopwatch_seconds = pStateReal->lifeData.dive_time_seconds - pStateReal->lifeData.internal.stopwatch_start_at_this_dive_time_seconds; | 1054 pStateReal->lifeData.stopwatch_seconds = pStateReal->lifeData.dive_time_seconds - pStateReal->lifeData.internal.stopwatch_start_at_this_dive_time_seconds; |
1043 | |
1044 /* wireless data | |
1045 */ | |
1046 uint16_t wirelessData[4][3]; | |
1047 for(int i=0;i<4;i++) | |
1048 { | |
1049 pStateReal->lifeData.wireless_data[i].ageInMilliSeconds = dataIn.data[dataIn.boolWirelessData].wireless_data[i].ageInMilliSeconds; | |
1050 pStateReal->lifeData.wireless_data[i].status = dataIn.data[dataIn.boolWirelessData].wireless_data[i].status; | |
1051 pStateReal->lifeData.wireless_data[i].numberOfBytes = dataIn.data[dataIn.boolWirelessData].wireless_data[i].numberOfBytes; | |
1052 for(int j=0;j<12;j++) | |
1053 pStateReal->lifeData.wireless_data[i].data[j] = dataIn.data[dataIn.boolWirelessData].wireless_data[i].data[j]; | |
1054 } | |
1055 | |
1056 // neu 160412 | |
1057 for(int i=0;i<4;i++) | |
1058 { | |
1059 if(pStateReal->lifeData.wireless_data[i].numberOfBytes == 10) | |
1060 { | |
1061 wirelessData[i][0] = (pStateReal->lifeData.wireless_data[i].data[0] >> 4) & 0x7F; | |
1062 wirelessData[i][1] = 0; | |
1063 wirelessData[i][2] = pStateReal->lifeData.wireless_data[i].ageInMilliSeconds; | |
1064 } | |
1065 else | |
1066 { | |
1067 wirelessData[i][0] = 0; | |
1068 wirelessData[i][1] = 0; | |
1069 wirelessData[i][2] = 0; | |
1070 } | |
1071 } | |
1072 | |
1073 // aussortieren doppelte ids, j�ngster datensatz ist relevant | |
1074 for(int i=0;i<3;i++) | |
1075 { | |
1076 if(wirelessData[i][0]) | |
1077 { | |
1078 for(int j=i+1; j<4; j++) | |
1079 { | |
1080 if(wirelessData[i][0] == wirelessData[j][0]) | |
1081 { | |
1082 if(wirelessData[i][2] > wirelessData[j][2]) | |
1083 { | |
1084 wirelessData[i][0] = wirelessData[j][0]; | |
1085 wirelessData[i][1] = wirelessData[j][1]; | |
1086 wirelessData[i][2] = wirelessData[j][2]; | |
1087 } | |
1088 wirelessData[j][0] = 0; | |
1089 wirelessData[j][1] = 0; | |
1090 wirelessData[j][2] = 0; | |
1091 } | |
1092 } | |
1093 } | |
1094 } | |
1095 | |
1096 /* PIC data | |
1097 */ | |
1098 for(int i=0;i<4;i++) | |
1099 { | |
1100 pStateReal->lifeData.buttonPICdata[i] = dataIn.data[dataIn.boolPICdata].button_setting[i]; | |
1101 } | |
1102 | |
1103 /* sensorErrors | |
1104 */ | |
1105 pStateReal->sensorErrorsRTE = dataIn.sensorErrors; | |
1106 } | 1055 } |
1107 | 1056 |
1108 | 1057 |
1109 uint8_t DataEX_check_RTE_version__needs_update(void) | 1058 uint8_t DataEX_check_RTE_version__needs_update(void) |
1110 { | 1059 { |