C API - I2C commands

Does the GrovePi support more complex I2C commands?

the first 5 work fine:
dRead_cmd 1
dWrite_cmd 2
aRead_cmd 3
aWrite_cmd 4
pMode_cmd 5

But the more complicated commands such as:
Ultrasonic_cm 7
DHT_sensor_cmd 40

Do not work.

I need to know, is this a short coming of the C API / I2C SMBBUS driver?
Should I drop this and attempt to integrate java into my applications instead?

Hi @alex.blake,

Sorry for the delay in testing things out. GrovePi does support have software support for Ultrasonic and DHT sensors.
We have got the Ultrasonic sensor to work with the C library and its still under testing though. Can you try out the following and tell us how well it works for you.

  1. Add the highlighted lines to grovepi.h

2. Add the following code at the end of the grovepi.c file

int ultrasonicRead(int pin)
{
int data;
write_block(uRead_cmd,pin,0,0);
usleep(60);
read_byte();
read_block();
data=r_buf[1]* 256 + r_buf[2];
if (data==65535)
	return -1;
return data;

}
3. Create an example called grovepi_us_read.c with sudo nano grovepi_us_read.c to test the ultrasonic sensor and add the following lines

# include "grovepi.h"

int main(void)
{		
	int adata;
	
	//Exit on failure to start communications with the GrovePi
	if(init()==-1)
		exit(1);
	
	while(1)
	{   # Connect the ultrasonic sensor to port D4
		adata=ultrasonicRead(4);
		printf("ultasonic read %d\n",adata);
		if(adata==-1)
			printf("IO Error");
	}
   	return 1;
}

4.Connect the Ultrasonic Sensor to Port D4.
5. Run the following to execute the code
sudo gcc grovepi_us_read.c grovepi.c -Wall
./a.out

Please let us know if this helps,
-Shoban