View unanswered posts | View active topics It is currently Tue Jul 17, 2018 3:33 pm






Reply to topic  [ 1 post ] 
Downloading source to robot corrupts firmware? 
Author Message
Rookie

Joined: Thu Oct 01, 2015 10:42 am
Posts: 1
Post Downloading source to robot corrupts firmware?
Hello all, I'm new to RobotC and robotics in general, but I've done a little bit of programming in the past for fun.
Anyways, I don't like the restrictions for ordinary arrays, so I tried making my own linked list data structure.
The problem is, even when I only make one node, it corrupts the firmware apparently because it makes the program crash and I can only seem to fix it by
re-downloading the firmware in the Robot program. Why is this happening? Is it my code? (I'm not a very good programmer lol)

Anyways, here's the code so far that causes problems.

Code:
#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, dgtl3,  Output,         sensorSONAR_cm)
#pragma config(Sensor, dgtl12, Rot,            sensorNone)
#pragma config(Sensor, I2C_1,  ,               sensorQuadEncoderOnI2CPort,    , AutoAssign)
#pragma config(Motor,  port2,           Neck,          tmotorVex393_MC29, openLoop, encoderPort, I2C_1)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//




// Linked List, contains a series of references to nodes, acts as an array without the size restrictions.

struct node
{
 int value;
 node*nextnode;
}

struct node* lastnode;


void appendtolist(int x)
{
 struct node* newnode;
 newnode->value=x;
 lastnode->nextnode=newnode;
}


float Revolutions()
{
 return SensorValue[I2C_1]/(float)650;
}

task main()
{

 struct node* root;
 lastnode=root;

 appendtolist(1);


 while(1+1==2)
 {
  int dist = SensorValue(Output);
  writeDebugStream("\nDist: %f, Revolutions: %f",dist,Revolutions());
  motor[Neck]=(dist<5?0:20);


  //start at 0,
  //-1 for left until full revolution
  // +1 for right until full revolution


 }
 motor[Neck]=0;
}


I know it's the linked list, because when I comment out appendtolist and everything the program works fine.


Thu Oct 01, 2015 10:49 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 2 guests


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 post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.