|
Page 1 of 1
|
[ 7 posts ] |
|
Help with Irlink sensor and HTRCXReadResp()
| Author |
Message |
|
cheechr1
Rookie
Joined: Sun Jan 23, 2011 3:14 am Posts: 8
|
 Help with Irlink sensor and HTRCXReadResp()
Hi. Im having a hard time getting my program to compile using this command. Example:
#pragma config(Sensor, S1, HTRCX, sensorI2CCustom)
#include "HTRCX-driver.h" int rcxmessage[0]; bool rcxmessagesuccess = 0; task main () { while (1==1) { if (HTRCXreadResp(HTRCX, rcxmessage,rcxmessagesuccess ) != 0) { rcxmessage = HTRCXreadResp(HTRCX, rcxmessage,rcxmessagesuccess); eraseDisplay();
nxtDisplayString(3, "RCX: %d", rcxmessage); } } }
Can someone please tell me the proper way to use this command? Thanks.
|
| Mon May 21, 2012 10:09 pm |
|
 |
|
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 528 Location: Totally not spying on Hassenplug to see what he has for the Brickworld Chicago 2013 sumo contest.
|
 Re: Help with Irlink sensor and HTRCXReadResp()
You want to display the message received from the RCX, right? I think that this code will accomplish that: (Please put your code in the tags next time.) I'm not positive, but I think this should work. I've never used the IRLink with the RCX in RobotC before.
_________________A.K.A. inxt-generation Self-proclaimed genius, and future world dominator. My Brickshelf Folder"Don't they teach recreational mathematics anymore?" - The Tenth Doctor Bow down to Nikola Tesla, King of the Geek Gods.
|
| Mon May 21, 2012 10:38 pm |
|
 |
|
mightor
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2906 Location: Rotterdam, The Netherlands
|
 Re: Help with Irlink sensor and HTRCXReadResp()
Try this code: Please note that HTRCXreadResp() is flaky at the best of times and dumps the whole register, so be sure to check more than just rcxmessage[0]. I never got it working reliably as a means to read something from the RCX. The buffer will be overwritten in the sensor whenever something new comes along. It's a real pain in the butt. - Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Tue May 22, 2012 12:17 am |
|
 |
|
cheechr1
Rookie
Joined: Sun Jan 23, 2011 3:14 am Posts: 8
|
 Re: Help with Irlink sensor and HTRCXReadResp()
Thanks guys I knew it was something simple. Ill report back on how I make out with this.
|
| Tue May 22, 2012 1:08 am |
|
 |
|
cheechr1
Rookie
Joined: Sun Jan 23, 2011 3:14 am Posts: 8
|
 Re: Help with Irlink sensor and HTRCXReadResp()
No problem sending to the RCX but receiving, as far as I can tell, is a no go.
|
| Tue May 22, 2012 4:22 am |
|
 |
|
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 528 Location: Totally not spying on Hassenplug to see what he has for the Brickworld Chicago 2013 sumo contest.
|
 Re: Help with Irlink sensor and HTRCXReadResp()
Did you try what Xander said and read the whole register? You can use a "for()" loop for that instead of typing out the display command 8 times.
_________________A.K.A. inxt-generation Self-proclaimed genius, and future world dominator. My Brickshelf Folder"Don't they teach recreational mathematics anymore?" - The Tenth Doctor Bow down to Nikola Tesla, King of the Geek Gods.
|
| Tue May 22, 2012 8:56 am |
|
 |
|
cheechr1
Rookie
Joined: Sun Jan 23, 2011 3:14 am Posts: 8
|
 Re: Help with Irlink sensor and HTRCXReadResp()
Im sorry im no programming expert, I use Robot C because NXT-G is almost unusable. I really dont know what you mean by "the whole register". Ill show you what I tried.. NXT Program: RCX Program: So far I am finding Robot C to be a great programming environment for the NXT its just when it comes to hex things and registers I become lost. Thanks for all the help and if you can think of any online sources where I could read on this a bit more I would be most grateful. Thanks again! Note: I am using Robot C 3.08 for the NXT and 2.03 for the RCX
|
| Tue May 22, 2012 1:20 pm |
|
|
|
Page 1 of 1
|
[ 7 posts ] |
|
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
|
|