To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 3216
3215  |  3217
Subject: 
Re: strange motor behaviour
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Wed, 2 Apr 2003 07:59:21 GMT
Viewed: 
2899 times
  
Marko Ortmueller wrote:
Hello,
I wonder if somebody can help me wíth the following problem.
In general my program is running okay but when I change the
attached data definition, the two motors I use show very strange
behaviour (just making some noise and moving very slow in random
directions).

with:
...
typedef char tilesTyp[10][20];
tilesTyp *tiles;
...
tiles=(tilesTyp *)malloc(sizeof(tilesTyp));
...
everything is fine
---
when I increase the size to for example:
...
typedef char tilesTyp[40][40];
...
the problem occurs.
Is there any size restriction when I allocate a dynamic block of memory?

well, the RCX only has 32Kbyte of memory of wich half is used by brickOs
the remaining half should fit you user programm and all runtime stacks
and heaps, so allocating 40*40*2Bytes(the minimum for a pointer in an
32Kbyte adresspace) will need 3.2Kb.

The RCX hasnt got any memory-protection either, therefor you can be
writing over the adressess where the motors get there data about speed
and direction..
so i guess with that malloc you're actually overwriting brickos's own
data...

Tom



Message has 1 Reply:
  Re: strange motor behaviour
 
(...) (this should be your user programm of course) (...) and i've been a bit too quick, it should be 40*40*1 (you're allocating char's), still thats' about 1.5kByte, that is, 1/10th of the memory available to you as user, so the following reasoning (...) (22 years ago, 2-Apr-03, to lugnet.robotics.rcx.legos)

Message is in Reply To:
  strange motor behaviour
 
Hello, I wonder if somebody can help me wíth the following problem. In general my program is running okay but when I change the attached data definition, the two motors I use show very strange behaviour (just making some noise and moving very slow (...) (22 years ago, 1-Apr-03, to lugnet.robotics.rcx.legos)

5 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR