Pārlūkot izejas kodu

Промежуточный коммит.

TelenkovDmitry 8 mēneši atpakaļ
vecāks
revīzija
527256eec3

+ 10 - 0
fw/modules/io/input.c

@@ -115,6 +115,16 @@ void in_set(void)
     }
 }
 
+//
+uint8_t in_get(uint8_t channel)
+{
+    uint8_t ret = 0;
+    
+    ret = (uint8_t)(input_state_bit >> channel & 1);
+    
+    return  ret;
+}
+
 //
 void io_test(void)
 {

+ 3 - 0
fw/modules/io/input.h

@@ -20,6 +20,9 @@ void in_exint_init(void);
 //
 void in_set(void);
 
+//
+uint8_t in_get(uint8_t channel);
+
 //
 void io_test(void);
 

+ 6 - 0
fw/modules/io/mux.c

@@ -82,6 +82,12 @@ mux_channel_t leds[LED_NUMBER] = {
                                   {IO_12_G, {0, 1, 1}, LED_OFF, 0},
                                   {IO_12_R, {0, 1, 1}, LED_OFF, 0},
 };
+
+#else
+//# defined (MAO_8)
+mux_channel_t leds[1] = {
+                                  {INP_1, {0, 0, 0}, LED_OFF, 0},
+                                 };
 #endif
 
 //

+ 48 - 3
fw/modules/io/mux.h

@@ -27,7 +27,7 @@
 #define COL_4_RESET    GPIOB->clr = GPIO_PINS_7
 
 /* -------------------------------------------------------------------------- */
-#if defined (MDIO_88)
+#if defined(MDIO_88)
 
 #define LED_NUMBER      28
 
@@ -69,8 +69,52 @@ typedef enum
     OUT_8_G,
       
 } led_t;
-/* -------------------------------------------------------------------------- */
-#elif defined (MAI_12)
+
+#elif defined(MAI_12)
+
+#define LED_NUMBER      28
+
+typedef enum
+{
+    IO_1_G = 0, 
+    IO_1_R, 
+    IO_2_G,
+    IO_2_R,
+    
+    IO_3_G,
+    IO_3_R,
+    IO_4_G,
+    IO_4_R,
+    
+    IO_5_G,
+    IO_5_R,
+    IO_6_G,
+    IO_6_R,
+    
+    STATUS_G,
+    STATUS_R,
+    RX_G,
+    TX_R,
+    
+    IO_7_G,
+    IO_7_R,
+    IO_8_G,
+    IO_8_R,
+    
+    IO_9_G,
+    IO_9_R,
+    IO_10_G,
+    IO_10_R,
+    
+    IO_11_G,
+    IO_11_R,
+    IO_12_G,
+    IO_12_R,
+    
+} led_t;
+
+//#elif defined (MAO_8)
+#else
 
 #define LED_NUMBER      28
 
@@ -113,6 +157,7 @@ typedef enum
     
 } led_t;
 #endif
+
 /* -------------------------------------------------------------------------- */
 
 typedef enum

+ 1 - 1
fw/modules/log/log.c

@@ -503,7 +503,7 @@ void archive_task(void *params)
                 DBG printf("Archive event: %u\r\n", (1 << i));
                 
                 entry.timestamp = 0;
-                entry.input_value = (uint8_t)input_state_bit;
+                entry.input_value = in_get(i - 1);
         
                 DBG printf("Append archive entry...");
                 ret = log_append((void*)&entry, ARCHIVE_ENTRY, i - 1);

+ 2 - 2
fw/modules/log/log_api.c

@@ -42,7 +42,7 @@ int log_get_archive_entry(uint32_t index, struct ringfs *fs, void *entry)
 	}
     
     log_fetch(entry, ARCHIVE_ENTRY, 0, portMAX_DELAY);
-#if 1
+#if 0
     printf("[archive entry] timestamp = % " PRId64 ", value = %u, crc = %u\r\n", 
            ent->timestamp, ent->input_value, ent->crc);
 #endif    
@@ -68,7 +68,7 @@ int log_get_log_entry(uint32_t index, struct ringfs *fs, void *entry)
     
     log_fetch(entry, LOG_ENTRY, 0, portMAX_DELAY);
    
-#if 1
+#if 0
 /*
     printf("[log entry] timestamp = % " PRId64 ", code_type = %u, code_state = %u, \
            channel_number = %u, value = %f, crc = %u\r\n", ent->timestamp, \

+ 9 - 1
fw/user/main.cpp

@@ -290,7 +290,15 @@ void test_hw_task(void *argument)
 {
     for (;;)
     {
-        vTaskDelay(100);
+        vTaskDelay(1000);
+        
+        
+        printf("\r\n");
+        for (uint8_t i = 0; i < 8; i++)
+        {
+            printf("Channel: %u, state = %u\r\n", i + 1, in_get(i));
+        }
+        
         
 #if 0      
         vTaskDelay(100);

BIN
output/fw.bin


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 405 - 422
project/ewarm/iap/iap.dep


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 551 - 559
project/ewarm/module_universal_io.dep


BIN
tools/__pycache__/io_module.cpython-310.pyc


BIN
tools/__pycache__/log_reader.cpython-310.pyc


BIN
tools/__pycache__/mb_registers.cpython-310.pyc


BIN
tools/__pycache__/modbus.cpython-310.pyc


BIN
tools/__pycache__/sys_params.cpython-310.pyc


BIN
tools/__pycache__/updater.cpython-310.pyc


+ 10 - 10
tools/log_reader.py

@@ -37,16 +37,16 @@ class LogParser(Parser):
     @staticmethod
     def print_entry(entry: tuple, index: int):
         timestamp = time.ctime(entry[0]/1000 - LogParser.utc_offset)
-        ans = f"[LOG] {index}: {LogParser.events[entry[1]]}, {timestamp}, state: {entry[2]}, channel: {entry[3]}, value: {entry[4]}"
+        ans = f"[LOG] {index:05}: {LogParser.events[entry[1]]}, {timestamp}, state: {entry[2]}, channel: {entry[3]}, value: {entry[4]}"
         print(Fore.CYAN + ans)
 
 
 class ArchiveParser(Parser):
 
     @staticmethod
-    def print_entry(entry: tuple, index: int):
+    def print_entry(entry: tuple, channel: int, index: int):
         timestamp = time.ctime(entry[0]/1000 - LogParser.utc_offset)
-        ans = f"[ARCHIVE] {index}: {timestamp}, value: {entry[1]}"
+        ans = f"[ARCHIVE] {index:05}: {timestamp}, value: {entry[1]}"
         print(Fore.CYAN + ans)
 
 
@@ -96,6 +96,7 @@ class LogReader:
 
 
 class DigitalLogReader(LogReader):
+    
     def __init__(self, modbus: Modbus):
         super().__init__(modbus)
 
@@ -119,8 +120,9 @@ class DigitalLogReader(LogReader):
         data = self.modbus.read_file_record(LOG_ENTRY, 0, index, 1)
         LogParser.print_entry(struct.unpack('<QBBBfB', data[5:21]), index)
 
-    # def print_archive_entry(self, index):
-
+    def print_archive_entry(self, channel, index):
+        data = self.modbus.read_file_record(ARCHIVE_ENTRY, channel, index, 1)
+        ArchiveParser.print_entry(struct.unpack('<QBB', data[5:15]), channel, index)
 
     def get_random_log_entry(self):
         data = self.modbus.read_file_record(LOG_ENTRY, 0, randint(1, self.log_entries_number), 1)
@@ -138,14 +140,12 @@ class DigitalLogReader(LogReader):
 
     def get_all_archive(self):
         self.get_log_info()
-        # print(self.archive_entries_number)
         for channel in range(0, len(self.archive_entries_number)):
-            # print(f"Archive channel {channel} {self.archive_entries_number[channel]}")
-            # print(self.archive_entries_number[channel])
             if (self.archive_entries_number[channel]):
-                print(f"Archive channel {channel}")
+                print(Fore.LIGHTGREEN_EX + f"Archive channel: {channel}")
                 for i in range(0, self.archive_entries_number[channel]):
-                    print(self.get_archive_entry(channel, i+1))
+                    self.print_archive_entry(channel, i + 1)
+
 
     def get_all_log(self):
         self.get_log_info()

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels