Main State Machine.  
More...
#include <stdint.h>
#include <stdio.h>
#include "kosteus.h"
#include "sht11.h"
State controls to main program flow
initialize HW ports for input and output
- Todo:
- Configure counter so, that timeout is 1 second 
- Todo:
- Change the counter to count every 100th message 
- Todo:
- This case is just for testing. To be modified to Report Slave ID 
2 is Place of datacount value in the ModBus Response Message 
 
 
      
        
          | unsigned int boot_counter =0 | 
      
 
 
      
        
          | unsigned int bus_comm_error_counter =0 | 
      
 
 
      
        
          | unsigned char datacount = 0 | 
      
 
 
      
        
          | unsigned char device_version[] = "$Revision: 248 $" | 
      
 
- Todo:
- Too many global variables 
 
 
      
        
          | unsigned char error_condition | 
      
 
 
      
        
          | unsigned int exception_error_counter =0 | 
      
 
 
      
        
          | unsigned int first_start_indicator | 
      
 
 
      
        
          | unsigned char laskuri = 0 | 
      
 
 
      
        
          | unsigned char length_of_ascii_hex_response = 0 | 
      
 
 
      
        
          | unsigned char length_of_message = 0 | 
      
 
 
      
        
          | unsigned char length_of_response = 0 | 
      
 
 
      
        
          | int measurement_number =0 | 
      
 
 
Totally received modbus frame 
 
 
      
        
          | unsigned char modbuss_address | 
      
 
 
      
        
          | volatile unsigned char nro_characters_received = 0 | 
      
 
 
      
        
          | volatile unsigned char nro_characters_to_be_sent | 
      
 
 
      
        
          | unsigned int number_of_points | 
      
 
 
      
        
          | unsigned char previouse_received_character | 
      
 
 
      
        
          | unsigned char query_type = 0 | 
      
 
 
      
        
          | unsigned long int receive_timeout | 
      
 
 
      
        
          | unsigned char received_character | 
      
 
 
Response frame to be sended to master 
 
 
      
        
          | unsigned int start_address | 
      
 
 
      
        
          | unsigned int sub_function | 
      
 
 
      
        
          | unsigned char transmit_buffer_begin | 
      
 
 
      
        
          | unsigned char transmit_buffer_current_pos |