Bounty for complete EV3 C/C++ API

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Bounty for complete EV3 C/C++ API

Post by HaWe »

thank you for your explanations!
the NXT color sensor is currently not so urgently needed because I may use the ev3 color sensor intermediately as a substitute.

What I still don't understand concerning i2c sensors:

How does the program know which address registers or data registers have to be read or written?
In case of the nxt USS in continuous mode I suspect you just need to read raw values at addr reg 0x02,
for the PCF8574 you need to send 2 bytes to addr 0x42 (or optionally switched to 0x70 or 0x72 using different IC settings) to get returned 1 byte which represents the bit mask of pressed (8) touch sensors
for the USS in single shot mode you first write 3 bytes (i.g., write "0x01" to i2caddr=0x02 and regaddr=0x42 {0x02, 0x41, 0x01}) and then read at {i2caddr=0x02, regaddr=0x42} 4 bytes which represent 4 different echoes

Code: Select all

// Lego US sensor in single shot mode

#define MAX_BYTES 4

const byte ping_cmnd[] = {0x2, 0x41, 0x1}; // sensor one-shot-mode command
const byte register_select[] = {0x2, 0x42}; // sensor data register

// Wait until Select button is bumped.
void wait_for_btnpressed()
{
   until (ButtonPressed(BTNCENTER, true));
   while (ButtonPressed(BTNCENTER, true));
}

// Ping the US sensor when the Select button is bumped.
task main()
{
   byte data[MAX_BYTES];
   byte data_size = MAX_BYTES;
   SetSensorLowspeed(IN_4);
   while (true)
   {
      TextOut(0,0,"press BtnCenter");
      wait_for_btnpressed();
      ClearScreen();
      I2CWrite(IN_4, 0, ping_cmnd); // send the ping command
      Wait(MS_50); // give sensor time to do the ping
      // Read and display the range data produced by the ping
      if (I2CBytes(IN_4, register_select, data_size, data))
      {
         for (int i = 0; i < MAX_BYTES; ++i)
            NumOut(40, 56 - 8 * i, data[i]);
      }
      else TextOut(0, LCD_LINE1, "Sensor Error");
   }
}
I have no idea which settings are needed for the XG1300L yet,
and I have no idea what to do if I plug 3 i2c sensors to 1 port like I already did before using a port splitter plus 3 i2c sensors (Lego USS_singleshot, PCF8574, MS RX MMux) and then poll them sequentially.
And then I'm also curious how to use the HT sensor multiplexer which also is an i2c device itself.

Do have an idea?
ulmeco
Posts: 7
Joined: 23 Jan 2014, 20:51

Re: Bounty for complete EV3 C/C++ API

Post by ulmeco »

doc-helmut wrote:thank you for your explanations!
the NXT color sensor is currently not so urgently needed because I may use the ev3 color sensor intermediately as a substitute.

What I still don't understand concerning i2c sensors:

How does the program know which address registers or data registers have to be read or written?
Actually my code doesn't do anything as low level as that - the EV3 firmware polls the sensors and stores raw data in shared memory, and I'm just accessing that memory.
doc-helmut wrote: I have no idea which settings are needed for the XG1300L yet,
and I have no idea what to do if I plug 3 i2c sensors to 1 port like I already did before using a port splitter plus 3 i2c sensors (Lego USS_singleshot, PCF8574, MS RX MMux) and then poll them sequentially.
And then I'm also curious how to use the HT sensor multiplexer which also is an i2c device itself.

Do have an idea?
I found NXC code for XG1300L here: http://www.minfinity.com/eng/page.php?M ... 1&tab=5exa
I guess there's a way to configure the sensor apart from setting sensor mode, that I wasn't aware of. As for the sensor data the code does this:

Code: Select all

		XglData.mAng = data[0] + data[1]*256;
		XglData.mRate = data[2] + data[3]*256;
		XglData.mAccX = data[4] + data[5]*256;
		XglData.mAccY = data[6] + data[7]*256;
		XglData.mAccZ = data[8] + data[9]*256;
So I would guess you could do the same thing with calling readSensorData():

Code: Select all

unsigned char* data = (unsigned char*)readSensorData(0);
unsigned short angle = data[0] + data[1]*256;
(etc.)
As for using a port splitter - I didn't know you could do that. If the EV3 firmware supports that and stores the data sequentially, it should be possible to do it by reading the shared memory. See https://github.com/carstenz/ev3sensor/b ... nsor/iic.h for how the EV3 firmware stores the sensor data for i2c devices in shared memory - the contents in that header is taken from lms2012.h.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Bounty for complete EV3 C/C++ API

Post by HaWe »

the EV3 firmware polls the sensors and stores raw data in shared memory
but how would the ev3 FW know what I actually wanted to do e.g., with a NXT US sensor?
maybe it detects this sensor automatically, but how would it change continuous mode to single shot mode?
and for the PCF8574, you may read the 8 pins (detect 8 touch sensors states at 8 pins), or you also may write data to it (put voltage to the pins e.g. to light up 1...8 LEDs) - how would I tell that the FW? (Not to mention that I actually doubt that autodetection would work for either device, like different PCF, MCP, or MAXIM chips.)

So the easiest (or at least: the most logical) way would be to read and write i2c commands just like one is doing by NXC or RobotC, then you can define addresses and registers and read and/or write them, even if there are plugged more than just 1 device at this port (i2c supports as generally known up to 127 chained devices at 1 port); in this case one would only have to adjust the address number in order to address a certain device, and this is just the way you're doing it by other µCs like, e.g., Arduinos. This concatenation is finally the outstanding advantage of the i2c protocol...!
ulmeco
Posts: 7
Joined: 23 Jan 2014, 20:51

Re: Bounty for complete EV3 C/C++ API

Post by ulmeco »

doc-helmut wrote: but how would the ev3 FW know what I actually wanted to do e.g., with a NXT US sensor?
maybe it detects this sensor automatically, but how would it change continuous mode to single shot mode?
If single shot mode is a mode that can be set like other sensor modes, then setSensorMode(port, mode) should work, if you know the mode number... otherwise I'm not sure.
doc-helmut wrote: and for the PCF8574, you may read the 8 pins (detect 8 touch sensors states at 8 pins), or you also may write data to it (put voltage to the pins e.g. to light up 1...8 LEDs) - how would I tell that the FW? (Not to mention that I actually doubt that autodetection would work for either device, like different PCF, MCP, or MAXIM chips.)
Hmm... I have no idea. :) I don't know enough about these protocols, and I didn't really plan to do anything that the EV3 firmware itself doesn't support.

Although, if you find a way to read/write i2c commands it sounds like it should just be a matter of porting the NXC code.
I wouldn't be surprised if it can be done using the various IIC structs and ioctl request codes defined in lms2012.h. Like "IIC_SETUP" for example. I already use IIC_SET_CONN to set the sensor mode.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Bounty for complete EV3 C/C++ API

Post by HaWe »

there is no mode setting for the Lego USS, for single shot mode it's just a couple of certain i2c write and read commands to make the device work this way.

You'd always have to send i2c write and read commands for either single i2c device.
But I don't know the syntax of any gcc i2c read or write commands. Can anyone else give me an example?

I am by far no low level programmer myself, for me already the lms2012 code is far too low-level...

But finally without having the i2c write and read commands all i2c hardware stuff is useless.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Bounty for complete EV3 C/C++ API

Post by HaWe »

finally I would support and expand the bounty mentioned in the TOP by another 200 EUR (270 USD), provided the following conditions are met:
  • The API fully supports all motors and sensors that come with the EV3 and those which are already compatible to the NXT, multiplexers included (if electrically possible).
  • auto-detection of devices can be disabled optionally, a manual sensor or motor configuration must be possible (SetSensor + SetMotor (type, mode) at master+daisy-chained bricks)
  • The API can be compiled with the CodeSourcery Lite toolchain version 2009q1-203 or provides a SD card image that works with your different operating system (e.g. Debian Linux), different compiler (e.g., C11 compatible), plus toolchains plus suitable USB device drivers (WiFi, LAN,memory stick, HID keyboard...).
  • Works on Windows XP32, Win7-32, Win7-64, and Windows 8 (Linux and/or Mac not necessary to me personally)
  • There should be a documentation of all API functions.
  • the API syntax for sensors and motors is close to RobotC, NXC, or the patterns described in here:
    https://sourceforge.net/apps/phpbb/mind ... 62&start=0
  • The API fully supports multiple IIC device concatening by a syntax close to NXC or RobotC
  • The API fully supports USB-daisy-chaining of at least 4 EV3 bricks, all remote I/Os accessable including multiple IIC devices concatenated at the slaves
  • The API supports preemptive multitasking (C11 standard or POSIX pthread)
  • the number of files which have to be included by 1 user robot program must not require more than three *.h API or compiler files (by #include), no additional linking to *.c files by a project manager and no later additional dynamical or static linking necessary any more
  • A single setup program is provided which installs all and everything on the PC: the IDE, the compiler including all libraries, toolchains, all compiler and path settings, all make file settings, no later manual re-adjustment needed (install and run!)
  • the custom firmware may be downloaded automatically to the EV3 flash to replace the complete Lego firmware or - optionally - can be stored automatically on a SD card plugged to the PC or already directly to the EV3
  • a context-sensitive help via editor -> [F1] -> doxygen API help file call with source code examples (like BCC for NXC)
  • 6 months warranty, online-support, bug-fixes, or refund
  • 100 EUR payed 1 month after completion of final release, the remaining 100 EUR payed after 6 months when bugs are fixed or at least reasonable workarounds exist
my bounty is limited to the end of March 2014.
mightor
Site Admin
Posts: 1079
Joined: 25 Sep 2010, 15:02
Location: Rotterdam, Netherlands
Contact:

Re: Bounty for complete EV3 C/C++ API

Post by mightor »

Do you realise how much work this is? Considering the average wage for a senior programmer in the EU is around 70 euro, this is less than 3 hours' worth of wage for more than a few months' full time work. You have commercial requirements but are unwilling to pay for them, good luck finding a someone, though.

Just so you know, even a programmer in Bangladesh makes this in about a week.

Your choices are:
  • Stop making ridiculous requirements for something you have no interest paying the proper amount for.
  • Make do with whatever the community is willing to give you (which, at the moment, doesn't look like a lot)
  • Pay someone a proper wage to create EXACTLY what you want. I can put you in touch with some developers that may be able to help you. Their rate is around 70 EU/hour. You're looking at about 30-35K EU for this, excluding the support contract. I am sure the community would appreciate such a project to be funded by someone so passionate about quality and usability such as yourself.
Bottom line is: in the open source world you don't get to make requirements unless you contribute.

= Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: Bounty for complete EV3 C/C++ API

Post by HaWe »

Xander,
I think you consider me to be more stupid than I actually am, don't you?

my offer was a list of my requirements - it was your own proposal you wrote me in a PM to pay people for those things that I need, and that is what it is (and that is what the TOP is about) - of course 2 people can not bear the entire cost alone.

What I have outlined in "my bounty" is actually nothing else than a program package like RobotC 4.0 - but for a compiler instead of a VM plus daisy chaining features, and I recognize just these following options:
  • If other people have other requirements, they should write what THEY want and what THEY are willing to pay for it.
  • RobotC will cost probably 100 EUR as well, and I in case I'd buy it I'll surely (or probably) won't be the only customer - the same thing it's about this issue.
    So I consider it to be sort of a crowd-funding / start-up project, and when many people agree to pay 100-200 EUR for what-ever, then a reasonable amount of a start-up capital will be accomplished.
  • If a programmer like you is willing to contribute something and to get payed for it, tell us what money you want and what you'll deliver for it.
There is no other way round.
blauskink
Posts: 1
Joined: 09 Feb 2014, 03:42

Re: Bounty for complete EV3 C/C++ API

Post by blauskink »

So I would definitely be joining it.
100, - € for the first version would then be no problem for me, but it would also be important that it will become more mature further on, so then I would be willing for to an additional 100, - Euro to be paid.

ps
If the first version is available, there's 100, - EUR guaranteed from me!

blauskink (mindstormsforum "skink")
alphasucht
Posts: 10
Joined: 27 Dec 2011, 14:30

Re: Bounty for complete EV3 C/C++ API

Post by alphasucht »

Start a crowdfund and we will see how many people will spend their money. There is nothing to lose. I will support it definitely.
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests