Post Go back to editing

Time Out Error with emStat pico

Category: Software
Software Version: v1.3

Hello,

Currently I use an emStat pico module interfacing stm32f4 microcontroller. Initially, I tested to get firmware version of the module, then I get it correctly. Here is the initial results:

EMSTAT_PICO Firmware Version: tespico1304#Oct 22 2021 14:3EMSTAT_PICO Firmware Version: tespico1304#Oct 22 2021 14:38:26
R*

Then I try to send the MethodScript, I get "e!0009: Line 1, Col ", '\0' <repeats 29 times>" error. Do you have any suggestion to solve the problem? Here is my code:

uint8_t firmware_version_response[36];
uint8_t response_buffer[50];
uint8_t firmware[2] = "t\n";
int isConnected = 0;

const char * dummy = "fs_dir /measurements\n";

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
	HAL_UART_Receive_IT(&huart3, response_buffer, 5);
}


int main(void)
{

HAL_Init();
 SystemClock_Config();
 
 MX_USART2_UART_Init();
  MX_USART3_UART_Init();
  /* USER CODE BEGIN 2 */
  HAL_UART_Receive_IT(&huart3, firmware_version_response, 36);
  HAL_UART_Transmit(&huart3, firmware, 2, 0xffff);

while (1)
  {
  if(isConnected == 0)
    	  {
    		  if(strstr(firmware_version_response, "espico") != NULL)
    		  {
    			  uint8_t fresponse[] = "EMSTAT_PICO Firmware Version: ";
    			  HAL_UART_Transmit(&huart2, fresponse, sizeof(fresponse), 0xffff);
    			  HAL_UART_Transmit(&huart2, firmware_version_response, 36, 0xffff);
    			  isConnected = 1;
    			  HAL_UART_Transmit(&huart3, dummy, sizeof(dummy), 0xffff);
    		  }

    		  else
    		  {
    			  isConnected = 0;
    		  }
    	  }
    	  }
    	  }

  • Hi AE104,

    This is a timeout error while waiting for a newline character. Either some data got lost in transmission, or the script is missing newlines. Are you giving the right size to your transmit function?

    Kind regards,
    Hielke

  • Hi  

    Thank you for your response, here is my new results. So what is the problem with that?

    tespico1304#Oct 22 2021 14:38:26
    R*
    e
    !0009
    M0000
    Pda7F0BE84u;ba7F04A4Dn,10,

    By the way here is my MethodScript that I sent:

    char const * sensor_data = "e\n"
    "var c\n"
    "var p\n"
    "set_pgstat_mode 2\n"
    "set_cr 100m\n"
    "cell_on\n"
    "meas_loop_lsv p c -1 1 10m 1\n"
    "pck_start\n"
    "pck_add p\n"
    "pck_add c\n"
    "pck_end\n"
    "endloop\n"
    "on_finished:\n"
    "cell_off\n"
    "\n";

    Here is the code callback and transmitting:

    void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
    {
    	HAL_UART_Receive_IT(&huart3, response_buffer, 40);
    	HAL_UART_Transmit(&huart2, response_buffer, sizeof(response_buffer), 0xffff);
    }
    
    
    while (1)
      {
    	  if(isConnected == 0)
    	  {
    		  if(strstr(firmware_version_response, "espico") != NULL)
    		  {
    			  uint8_t fresponse[] = "EMSTAT_PICO Firmware Version: ";
    			  HAL_UART_Transmit(&huart2, fresponse, sizeof(fresponse), 0xffff);
    			  HAL_UART_Transmit(&huart2, firmware_version_response, 36, 0xffff);
    			  isConnected = 1;
    			  HAL_UART_Transmit(&huart3, sensor_data, 151, 0xffff);
    		  }
    
    		  else
    		  {
    			  isConnected = 0;
    		  }
    	  }
    	  }
    

  • It looks like you are sending a command while a script is running, try looking up the error code in the MethodSCRIPT documentation.