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 CCS Technical Support

Saving float value on DS1302
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
MAKInnovation



Joined: 16 Nov 2010
Posts: 61

View user's profile Send private message

PostPosted: Wed Mar 13, 2013 11:49 pm     Reply with quote

Thank you all and specially Ttelmah for helping me in my project work:
This is the reply i am now recieving with my software
Tx:01 03 00 00 00 08 44 0C
Rx:01 03 10 00 88 00 77 00 66 00 55 00 44 00 33 00 22 00 11 9B 94

Thanks again & best Regards;
Ashraf
MAKInnovation



Joined: 16 Nov 2010
Posts: 61

View user's profile Send private message

PostPosted: Wed Mar 20, 2013 12:21 am     Reply with quote

Code:

while(TRUE)
   {
      while(!modbus_kbhit());
...................................
default:    //We don't support the function, so return exception
               modbus_exception_rsp(MODBUS_ADDRESS,modbus_rx.func,ILLEGAL_FUNCTION);
         }
      }

My code // which does not run
     


Here my code does not run because the program stuck at
while(!modbus_kbhit());
line
Code work fine when i continuously query data but it stuck when i stop my query

how can i resolve this problem?
Thanks
Ashraf
MAKInnovation



Joined: 16 Nov 2010
Posts: 61

View user's profile Send private message

PostPosted: Wed Mar 20, 2013 12:43 am     Reply with quote

Code:
while(!modbus_kbhit()&&(++timeout<50000)); // 1/2 second

I use this line instead of
Code:
while(!modbus_kbhit());

and now code is working.

And now trying to imlement RS485.

Thanks
Ashraf
MAKInnovation



Joined: 16 Nov 2010
Posts: 61

View user's profile Send private message

PostPosted: Tue Mar 26, 2013 4:16 am     Reply with quote

Dear All;
I am still in the process of finalizing my code and i found 1 more problem which i want to resolve and need guidance.
Code:

      timeout = 0;
      while(!modbus_kbhit()&&(++timeout<50000)); // 1/2 second


When i use this peace of code send a query to my slave pic from PC, the slave PIC send the reply on continuous basis after every second.
until i send the query with different address.

Code:


      while(!modbus_kbhit());


and when i use this peach of code in while(1) loop the program stuck at this line and i am unable to execute my other part of code.

Where would i fix this code or what am i doing wrong
Regards;
Ashraf
temtronic



Joined: 01 Jul 2010
Posts: 9241
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Tue Mar 26, 2013 5:46 am     Reply with quote

How have you declared the variable 'timeout'?
Actually a complete program would be helpful now after so many changes.

hth
jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19535

View user's profile Send private message

PostPosted: Tue Mar 26, 2013 5:54 am     Reply with quote

I think what you would need, is:
Code:

      timeout = 0;
      while(!modbus_kbhit()&&(++timeout<50000))
          ; // 1/2 second
      if (timeout<50000)
      {
          //Put the Modbus reply code here

      }
      //Then the other code


As shown in the original post, the code will think there _has_ been a query request, when timeout triggers, and so will send the reply.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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