473,385 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Coding problem

Further to my post the other day:
I am using Interactive C with my Handboard (68HC11) development system but
I've got a problem that I am asking for help with.

I have my code listed at http://www.fr33z3.net/code.txt

Symptom:
Programs fail ' Runtime error' which equates to a stack error.
This is because my code is like going around and around (a snake chasing its
tail is a term I've seen used)
but I cant work out how to overcome this problem.

Any help would be much appreciated.

Thanks
Jeff

Nov 13 '05 #1
3 2194
On Sun, 31 Aug 2003 18:16:13 +1000, "snowdy"
<sn****@optusnet.com.au@nospam> wrote:
Further to my post the other day:
I am using Interactive C with my Handboard (68HC11) development system but
I've got a problem that I am asking for help with.

I have my code listed at http://www.fr33z3.net/code.txt

Symptom:
Programs fail ' Runtime error' which equates to a stack error.
This is because my code is like going around and around (a snake chasing its
tail is a term I've seen used)
but I cant work out how to overcome this problem. // Variables used throughout the program

int range = 27;
int diff = 28;
int top = 19;
int current = 30;
int greyA = 26;
int greyB = 25;
int compass = 21;
int solenoid = 7;
int kick = 10;
int power = 9;
int sensors = 15;
int placement;
int value;
int ambient = 34;
int ambient_left = 121;
int ambient_right = 111;
int ambient_top = 165;
int ambient_diff = 116;
int attempt = 1;

// Start of Real Program

void main()
int main()
{
init_expbd_servos(1);
It's a good idea to declare functions before using them (i.e.
include a prototype)
start_process(direction());
Two more functions called without a declaration.

Furthermore note that this calls direction() and passes its
return value into start_process() as it's parameter value.
The significance of this will be apparent later.

[snip]
void direction()
OK. So direction() doesn't return a value. This makes the
call to direction() an error.
{
while(1)
{
if(analog(diff) > ambient_left)
{
placement = 1;
}
if(analog(diff) < ambient_right)
{
placement = 1;
}
}
}


And direction() itself is an infinite loop! Therfor your
program will never get as far as the call to start_process().

I have to make a guess here that maybe the line in main()
should have read:

start_process(direction);

This calls start_process() and passes as the parameter value the
address of the function direction().

If you include valid prototypes for all the functions you call this
would have been immediately obvious. It should also point you to
several instances of mis-matched parameter types that are in your
code.

Nick.

Nov 13 '05 #2
Thanks for your help nick, however, this isnt the problem that we have. A
lot of the problems that you spoke of are actually a feature of IC that we
are taking advantage of. Interactive C contains libraries of commands that
you can call such as init_expbd_servos(int) and start_process(function) that
you can use to do different things.
It's a good idea to declare functions before using them (i.e.
include a prototype)

See above
start_process(direction());


Two more functions called without a declaration.

Furthermore note that this calls direction() and passes its
return value into start_process() as it's parameter value.
The significance of this will be apparent later.


I understand the point that you are making with the passing of values.
However, the start_process command begins multitasking within the Handyboard
processor so that you may have 2 functions sharing processor time and
running concurrently. Usualy this type of command would pass the result of
direction to start_process, but in this case it begins a multitask of
direction and main.
void direction()
OK. So direction() doesn't return a value. This makes the
call to direction() an error.


See above, the call to direction starts multitasking, not return an int
value
{
while(1)
{
if(analog(diff) > ambient_left)
{
placement = 1;
}
if(analog(diff) < ambient_right)
{
placement = 1;
}
}
}


And direction() itself is an infinite loop! Therfor your
program will never get as far as the call to start_process().


See above again, the infinite loop is required so that the multitask is
maintained. Once the process is started, the main task continues so this
will not cause a problem in the HB.
I have to make a guess here that maybe the line in main()
should have read:

start_process(direction);

This calls start_process() and passes as the parameter value the
address of the function direction().

If you include valid prototypes for all the functions you call this
would have been immediately obvious. It should also point you to
several instances of mis-matched parameter types that are in your
code.


The prototypes are all included in libraries, so you do not have to create
these functions yourself. Similarly, with the example you used, I believe
the parameters are matched correctly (IC is able to debug this anyway).

Thankyou for your help nick, but I do not believe that this is the problem.
Do you have any other ideas?

TIA

Jeff
Nov 13 '05 #3
Think I have fixed it now...

terminated the functions that were causing the recursion!

Thank you for your comments, they helped me step through it

Jeff/Fr33tyl3r
Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Berthold Höllmann | last post by:
I have a default coding header # -*- coding: iso-8859-15 -*- in my python files. I now have Problems with this settings. I swithched to Python 2.4.1 under Windows. When I import files with the...
2
by: manning_news | last post by:
Has anyone had a problem with Access 2003 not saving their coding? I've been using 2003 for a couple of months now and just this week noticed that some coding I'd done for a database was not there...
144
by: Natt Serrasalmus | last post by:
After years of operating without any coding standards whatsoever, the company that I recently started working for has decided that it might be a good idea to have some. I'm involved in this...
1
by: R Reyes | last post by:
Hello All, I'm always looking for ways to improve my code. Most of the time (whenever I'm working on a project) I write a bunch of functions. Then after the project is finished, I put all the...
20
by: TJ Doherty | last post by:
Need help understanding the following please: When I am creating a project and code my connection using Dim connectString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data...
4
by: Josh Golden | last post by:
i lead a small development team (based on some of my posts that might cause some people to choke themselves, but have no fear, i am NOT the lead developer, the people on my team are great - i'm...
8
by: Ilias Lazaridis | last post by:
Where can I find practical coding examples for real life coding problems? Something like a categorized solution guide? - My current problem: * create a folder * seems to be:...
7
by: Robert Seacord | last post by:
The CERT/CC has just deployed a new web site dedicated to developing secure coding standards for the C programming language, C++, and eventually other programming language. We have already...
0
by: pat | last post by:
CodeCheck Coding Standard's Support As a free service to our customers we offer support in developing "rule-files" for automating corporate coding standards. If you have a coding standard that...
8
by: =?ISO-8859-1?Q?Arnaud_Carr=E9?= | last post by:
Hi all, I guess you all know how difficult it is to choose a conding standard. And even more difficult it is to explain the choice to your dev team :-) I'm looking for an "official" c++ coding...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.