Welcome, Guest. Please Login.
Surveyor Corporation Surveyor SRV-1
Home Help Search Login

Surveyor Robotics Forum

Welcome to the user support forum for Surveyor SRV-1 robots, SRV-1 robot controllers and SVS stereo vision systems. To register for this forum, please send an email to support@surveyor.com which includes your desired forum user name, your registration email address, and a brief explanation of why you wish to join, and we will create a forum account for you.

Please note that there is a Search button in the forum toolbar for forum topics. Another effective search method for the entire surveyor.com site is to use Google, e.g. "xyz site://www.surveyor.com" where "xyz" is the search topic.



Pages: 1 2 3 4 
Send Topic Print
Executing C-programs (Read 31735 times)
admin
YaBB Administrator
*****




Posts: 3676
Re: Executing C-programs
Reply #30 - 04/23/08 at 3:39pm
 
Try control-[  (control - left bracket), followed by <enter>, if it won't accept ESC
 
The ARM7 C didn't have a sonar() call.
 
Back to top
 
« Last Edit: 04/23/08 at 3:45pm by admin »  

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
randy
YaBB Newbies
*




Posts: 32
Re: Executing C-programs
Reply #31 - 04/24/08 at 1:09am
 
I have tested some case:
 
print(time());
=> semicolon expected in print(time());
 
int t1 = time();
print(t1);
=> semicolon expected in int t1 = 0
 
int t1;
t1 = time();
print(t1);
=> output 366925, no error
 
 
Besides, does sonar connect to pin 27-30, and then data received from C-function sonar()?
Sorry I don't find the information yet.
Back to top
 
« Last Edit: 04/24/08 at 2:10am by randy »  
  IP Logged
admin
YaBB Administrator
*****




Posts: 3676
Re: Executing C-programs
Reply #32 - 04/24/08 at 6:20am
 
That's good information - it appears that the C interpreter is unable to evaluate functions that are called within other functions.
 
Inputs from sonar modules (Maxbotics) are connected to pins 27-30, and the output trigger is connected to pin 18.  Details are here -  
    http://www.surveyor.com/cgi-bin/yabb2/YaBB.pl?num=1202831771
 
Note that the sonar() code recognizes whether or not a sonar module is connected, returning 0 for each module that isn't connected.
Back to top
 
 

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
randy
YaBB Newbies
*




Posts: 32
Re: Executing C-programs
Reply #33 - 04/24/08 at 6:19pm
 
Thanks!
It's helpful. We do have the idea to add sensors.
Back to top
 
 
  IP Logged
alarw
YaBB Newbies
*




Posts: 31
Re: Executing C-programs
Reply #34 - 04/30/08 at 10:22pm
 
I have been trying to upload the small hello c program to the flash memory using the nc command process you have listed but it doesn't appear to be working.  I am using Linux and I run nc 169.254.0.7 from the terminal window and then type zc and it says ##zclear buffer but when I type E then enter then i then enter nothing seems to happen.  I then paste your c code into the window and then use Esc then x and when I type zd nothing happens.  Can you please post a screenshot so I can see the exact sequence?
Back to top
 
 
  IP Logged
admin
YaBB Administrator
*****




Posts: 3676
Re: Executing C-programs
Reply #35 - 04/30/08 at 10:43pm
 
'E' just gets you into the editor, and should provide a command menu.  'i' initiates the insert mode, at which point you can paste code, terminated by ESC <enter>, then 'x' to exit back to the monitor.
 
What version of firmware are you running ?  The editor was only added in March or thereabouts.
Back to top
 
 

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
alarw
YaBB Newbies
*




Posts: 31
Re: Executing C-programs
Reply #36 - 05/01/08 at 10:00am
 
Thanks for the info.  I tried the 031108 version of firmware and it worked great.  There must be something wrong with the 032308 version I was originally using.  I will download it and try again.  Thanks for the help.
Back to top
 
 
  IP Logged
admin
YaBB Administrator
*****




Posts: 3676
Re: Executing C-programs
Reply #37 - 05/01/08 at 11:10am
 
Latest firmware is 042808 - you might give it a try.
Back to top
 
 

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
wmcnab
YaBB Newbies
*




Posts: 30
Re: Executing C-programs
Reply #38 - 05/07/08 at 3:44pm
 
I finally got back to trying various things and have some interesting results:
 
Using linux and netcat I was able to get the inf/then statements to work on my original srv1b.  It has no sonar but it does seem to work correctly.
I was also able to get it to work using netcat and XP once you suggested I try ctrl [ enter for escape.  I had no luck at all with shamcom.
 
However, on the blackfin on my rover, with the 90 degree camera connector, it just doesn't work.  I tried netcat xp, netcat linux, manually entering the data, etc.  The program looks fine but it just ignores the if/then statements.
Back to top
 
 
  IP Logged
admin
YaBB Administrator
*****




Posts: 3676
Re: Executing C-programs
Reply #39 - 05/07/08 at 4:24pm
 
Can you provide an example of the if/then code ?
Back to top
 
« Last Edit: 05/07/08 at 4:24pm by admin »  

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
wmcnab
YaBB Newbies
*




Posts: 30
Re: Executing C-programs
Reply #40 - 05/08/08 at 6:11am
 
I used the code you suggested earlier:
 
main()
{
  int x;
  x = sonar(1);
  if (x <= 1200)
    print("stop");
  else
    print("drive");
}  
 
If I put a print statement before the if statement, it prints fine, but nothing happens afterwards.  
 
I get no error codes or anything, it just goes on waiting for another command.
 
Can you think of anything else I can try?
Back to top
 
 
  IP Logged
admin
YaBB Administrator
*****




Posts: 3676
Re: Executing C-programs
Reply #41 - 05/08/08 at 6:23am
 
Got it.  The "if" statement by itself works okay, but "if" / "then" needs brackets ...
 
main() {
  int x;
  x = sonar(1);
  print("x = " x);
  if (x <= 1200) {
    print("stop");
  } else {
    print("go");
  }
}
 
I will update SRV_protocol_bf to reflect this.
Back to top
 
« Last Edit: 05/08/08 at 6:47am by admin »  

SRV-1 Development Team
Surveyor Corporation
Email WWW   IP Logged
wmcnab
YaBB Newbies
*




Posts: 30
Re: Executing C-programs
Reply #42 - 05/09/08 at 1:36pm
 
This does seem to work!  Now I'll have to put everything back together and see how it goes.
 
Thanks!
Back to top
 
 
  IP Logged
ucrobotics_ZW
YaBB Newbies
*




Posts: 14
Re: Executing C-programs
Reply #43 - 11/12/10 at 2:38am
 
I have met the same problem when exec C programs with "E" command.
 
See my log:
Code:
#?zd
##zdump: 

main()
{
printf("hello");
}

#?Q
{
 ^
test.c:3: 'main' is undefined
leaving picoC

#?
 


But if i only run the "printf", it works:
Code:
#?zd
##zdump: 

printf("hello");

#?Q
hello
starting picoc
> - ^[
leaving picoC
#? 


 
So it seems the "main()" function can not be accepted here. What's the reason ?
 
Another question: In page "http://www.surveyor.com/C.html", only "printf" is definded, but all of above demo are using "print", do you think it can works ?
 
I'm using the latest firmware.
Back to top
 
 
Email   IP Logged
tjump
Global Moderator
*****




Posts: 411
Re: Executing C-programs
Reply #44 - 11/12/10 at 6:40am
 
picoC does not recognize main(); so do not use it with picoC.
 
As far as print I always use printf(); Not sure why they are not using this in the examples above.
 
Cheers,
T. Jump
Back to top
 
« Last Edit: 11/12/10 at 6:45am by tjump »  
  IP Logged
Pages: 1 2 3 4 
Send Topic Print