IowKitWrite

This is the English forum for all topics related to IO-Warrior. Please post in English only

Moderator: Guido Körber

Post Reply
eamo
Posts: 12
Joined: Fri Jul 09, 2010 11:15 am

IowKitWrite

Post by eamo »

I am having trouble trying to write to a device, i tried using the example in the Help Doc-

Code: Select all

   ioHandle = IowKitOpenDevice();
	ULONG numPipe=1;
	IOWKIT24_IO_REPORT report;
	report.ReportID = 40;
	report.Value = 255;	  
   ULONG rc=IowKitWrite(ioHandle,numPipe,&report,IOWKIT24_IO_REPORT_SIZE);
returning this error:

Code: Select all

        error C2664: 'IowKitWrite' : cannot convert parameter 3 from 'IOWKIT24_IO_REPORT *' to 'PCHAR'
when using the SimpleI2C example i type 28 01 FF into the write line to get what i want but im having trouble coding this into my test program.

Thanks in advance
Eamonn
Guido Körber
Site Admin
Posts: 2856
Joined: Tue Nov 25, 2003 10:25 pm
Location: Germany/Berlin
Contact:

Re: IowKitWrite

Post by Guido Körber »

What are you trying to do?

You are writing to the second interface, and you are specifying the report length for the first interface.
eamo
Posts: 12
Joined: Fri Jul 09, 2010 11:15 am

Re: IowKitWrite

Post by eamo »

I am trying to use the device to control a light source,
to turn the light on I need to send 255 to it so I entered this to the example in hex and it worked, so the address is correct, I would step through the example source code to find my answer but I am using Visual Studio Express and cannot compile the code.
The data I need to send is:
Address: 40 (28)
sub-address: 1 (01)
Data: 255 (FF)
User avatar
Christoph Jung
Posts: 670
Joined: Sun Oct 08, 2006 3:43 pm
Location: Germany / Berlin
Contact:

Re: IowKitWrite

Post by Christoph Jung »

Type this:

Code: Select all


   IOWKIT24_IO_REPORT report;
   memset(&report, 0, IOWKIT20_IO_REPORT_SIZE); //Set var report to 0 for protect mal-function
   report.ReportID = 40;
   report.Value = 255;     

ULONG rc=IowKitWrite(ioHandle, numPipe, (char*) &report, IOWKIT24_IO_REPORT_SIZE);
Abteilung: Softwareentwicklung
Folge uns auf Twitter
Follow us on twitter
eamo
Posts: 12
Joined: Fri Jul 09, 2010 11:15 am

Re: IowKitWrite

Post by eamo »

It compiles with this but still nothing happening.
User avatar
Christoph Jung
Posts: 670
Joined: Sun Oct 08, 2006 3:43 pm
Location: Germany / Berlin
Contact:

Re: IowKitWrite

Post by Christoph Jung »

Our programms will create with Visual Studio Pro and the MFC. This is not included in the express version of VS.

Will you Write to the IO-Function oder to the Special-Mode of the IO-Warrior?

For the IO-Function you mut change your numPipe to 0.
Or use

IOW_PIPE_IO_PINS for 0
IOW_PIPE_SPECIAL_MODE for 1


For the Special-Mode you must use IOWKIT24_SPECIAL_REPORT(_SIZE) not IOWKIT24_IO_REPORT SIZE
Abteilung: Softwareentwicklung
Folge uns auf Twitter
Follow us on twitter
eamo
Posts: 12
Joined: Fri Jul 09, 2010 11:15 am

Re: IowKitWrite

Post by eamo »

I downloaded the Visual Studio 2010 trail and traced through the code, when using IOWKIT_SPECIAL_REPORT i noticed that report.Bytes[2]-[4] contain my 40,1,255. But what do ReportID, Bytes[0] and Bytes[1] represent?

Code: Select all

                       
report.ReportID = 0x02;
report.Bytes[0] = 0xC1 + send;
report.Bytes[1] = adresse;
User avatar
Christoph Jung
Posts: 670
Joined: Sun Oct 08, 2006 3:43 pm
Location: Germany / Berlin
Contact:

Re: IowKitWrite

Post by Christoph Jung »

I cannot follow you. What will you do with your programm?
Will you use the IO-Pins or the Special mode?
Abteilung: Softwareentwicklung
Folge uns auf Twitter
Follow us on twitter
Guido Körber
Site Admin
Posts: 2856
Joined: Tue Nov 25, 2003 10:25 pm
Location: Germany/Berlin
Contact:

Re: IowKitWrite

Post by Guido Körber »

Back to square 1, you are going about this totally wrong.

First of all, if you want to talk to simple I/O you have to write to Pipe 0, which is the first interface.

Second, when writing to Pipe 0 the ReportID HAS to be $00, otherwise a totally wrong report format will be transmitted that is going to be ignored by the IO-Warrior

Third, there are no address or sub address things involved with simple I/O.
eamo
Posts: 12
Joined: Fri Jul 09, 2010 11:15 am

Re: IowKitWrite

Post by eamo »

After tracing through the source code for Simple-IIC i got it work with this code:

Code: Select all

      IOWKIT_SPECIAL_REPORT report;
      memset(&report, 0, IOWKIT_SPECIAL_REPORT_SIZE);
 
      report.ReportID = 2;
      report.Bytes[0] = 196;
      report.Bytes[1] = 80;
      report.Bytes[2] = 40;
      report.Bytes[3] = 01;
      report.Bytes[4] = 255;

      ULONG rc=IowKitWrite(ioHandle, IOW_PIPE_SPECIAL_MODE, (char*) &report, IOWKIT_SPECIAL_REPORT_SIZE);
However I dont understand what these values represent?

Code: Select all

      report.ReportID = 2;
      report.Bytes[0] = 196;
      report.Bytes[1] = 80;
Thanks for all your help so far.
User avatar
Christoph Jung
Posts: 670
Joined: Sun Oct 08, 2006 3:43 pm
Location: Germany / Berlin
Contact:

Re: IowKitWrite

Post by Christoph Jung »

This code is for use the IIC Interface NOT for the SimpleIO. Take a look into the SimpleIO sample into the SDK.
Abteilung: Softwareentwicklung
Folge uns auf Twitter
Follow us on twitter
Guido Körber
Site Admin
Posts: 2856
Joined: Tue Nov 25, 2003 10:25 pm
Location: Germany/Berlin
Contact:

Re: IowKitWrite

Post by Guido Körber »

Please have a look at the documentation. The IO-Warrior Datasheet contains the specification of the functions.
eamo
Posts: 12
Joined: Fri Jul 09, 2010 11:15 am

Re: IowKitWrite

Post by eamo »

I have read through the data sheet but it didn't help much, it seems more directed to the electrical side of things, and I couldn't get the SimpleIo example to work, I simply want to write 1 byte to my device:

DeviceId = 40;
Address = 1;
Data = 0 - 255;

i have been using the following code:

Code: Select all

for(int i = 0; i < 255; i++)
	  {
	    Write(ioHandle,40,1,i);
		cout << i << endl;
		Sleep(20);
	  }

Code: Select all

void Write(IOWKIT_HANDLE ioHandle, int deviceId, int address, byte data)
{
	IOWKIT_SPECIAL_REPORT report;
    memset(&report, 0, IOWKIT_SPECIAL_REPORT_SIZE);

    report.ReportID = 0x02;
    report.Bytes[0] = 0xc1 + 1;
    report.Bytes[1] = deviceId << 1;
    report.Bytes[2] = data;
    //report.Bytes[3] = address;

    ULONG rc=IowKitWrite(ioHandle, IOW_PIPE_SPECIAL_MODE, (char*)&report, IOWKIT_SPECIAL_REPORT_SIZE);
}
i know it isn't correct but I am getting some sort of output with it, it should make my light source fade on as data increases from 0 to 255 but instead the light alternates on and off every 8 bytes. when the fourth bit is 0 the light is off and when it is 1 the light is fully on.

0000 0000 - light off
0000 0001 - light off
0000 0010 - light off
0000 0011 - light off
0000 0100 - light off
0000 0101 - light off
0000 0110 - light off
0000 0111 - light off

0000 1000 - light on
0000 1001 - light on
0000 1010 - light on
0000 1011 - light on
0000 1100 - light on
0000 1101 - light on
0000 1110 - light on
0000 1111 - light on

0001 0000 - light off
....
Guido Körber
Site Admin
Posts: 2856
Joined: Tue Nov 25, 2003 10:25 pm
Location: Germany/Berlin
Contact:

Re: IowKitWrite

Post by Guido Körber »

This is starting to feel a bit like Jeopardy. Some information to go with your question would actually enable us to help you. Since we don't know your hardware setup or what you are trying to do this is not exactly easy.

So you have some kind of I2C device connected to the IOW24? And there is a light connected to that device?

Assuming that you already did enable the I2C function of the IO-Warrior your code is correct to send the address and one byte of data to that device, assuming that the I2C address of that device is %1000000x.

Since I have no idea what device you have there I am in no position to make any guess as to what the data you are sending to it might give as a result.
Post Reply