CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

CCS Modbus library hangups

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
snock



Joined: 10 Oct 2011
Posts: 24

View user's profile Send private message

CCS Modbus library hangups
PostPosted: Mon Aug 05, 2013 6:51 am     Reply with quote

I am using the CCS modbus library from v1.124 and am experiencing a rare hang up. I have enabled the WDT on the part (PIC18F2680) but I am not sure that the micro itself is hanging. I have a red/green LED which indicates whether the unit is receiving or transmitting. I toggle the green side of it when something comes in. I notice that when the hangups occur that the green LED never gets toggled off so I am beginning to think that perhaps the unit only received a partial packet from the PC host and then hung up because the modbus_serial_new variable never got cleared. Here is the section of code that I think may be at fault:
Code:

void incomming_modbus_serial() {

   char c;
   output_low(LED_GRN); // Turn on green side of Comm. LED
   c=fgetc(MODBUS_SERIAL);

   if (!modbus_serial_new)
   {
      if(modbus_serial_state == MODBUS_GETADDY)
      {
         modbus_serial_crc.d = 0xFFFF;
         modbus_rx.address = c;
         modbus_serial_state++;
         modbus_rx.len = 0;
         modbus_rx.error=0;
      }
      else if(modbus_serial_state == MODBUS_GETFUNC)
      {
         modbus_rx.func = c;
         modbus_serial_state++;
      }
      else if(modbus_serial_state == MODBUS_GETDATA)
      {
         if (modbus_rx.len>=MODBUS_SERIAL_RX_BUFFER_SIZE) {modbus_rx.len=MODBUS_SERIAL_RX_BUFFER_SIZE-1;}
         modbus_rx.data[modbus_rx.len]=c;
         modbus_rx.len++;
      }

      modbus_calc_crc(c);
      modbus_enable_timeout(TRUE);
      output_high(LED_GRN); // Turn off green side of Comm. LED
   }
}


If anyone has any pointers it would be much appreciated. BTW, I do have ERRORS set on the #use rs232 line.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group