IOWarrior24VP write failure

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

Moderator: Guido Körber

Post Reply
hytecinc
Posts: 9
Joined: Mon Jun 19, 2006 9:55 pm

IOWarrior24VP write failure

Post by hytecinc »

The new software (beta) helped the basic access problem. I am now able to open a connection, retrieve version information, chip revision, serial number, etc.

But when I try writing to the chip it either fails writing zero bytes or hangs depending on which pipe I write to. For example, I am trying to retrieve the power status. Here is my code:

Code: Select all

char arrReport[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
   unsigned long intReturn;

   arrReport[0] = 20;

   intReturn = IowKitWrite( hndIOW, 1, arrReport, sizeof(arrReport) );

   if ( intReturn != sizeof(arrReport) ) {
      memLog->Lines->Add( "Failed to write to the IOW. Return = " + String( intReturn ) );
   }
   else {
      memLog->Lines->Add( "Response = " + String( (int)arrReport[1] ) );
   }

It just hangs at the write. Am I doing something wrong? I have verified that the handle is open and working at this point.

Here is the information I was able to retrieve from the chip:

Code: Select all

IowKit Version IO-Warrior Kit V1.5
Opening Device...
Opened the device.
There is/are 1 device(s) connected.
Device #1
13697044: Is an unknown IOW (5394)
13697044: Revision 4131
13697044: Serial #00000224

Thanks for the help.
wayoda
Posts: 362
Joined: Fri Dec 19, 2003 12:00 pm
Location: Wuppertal/Germany

Post by wayoda »

Hello hytecinc,

I never worked with a IOW24PV and I didn't test the Software Beta so this is just a suggestion:

You try to retrive the power status of the chip with the SpecialMode-command

Code: Select all

char arrReport[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; 
unsigned long intReturn; 
 
 arrReport[0] = 20; 
intReturn = IowKitWrite( hndIOW, 1, arrReport, sizeof(arrReport) ); 
but all the values for specialmode-sequences that start with $ are Hex-values.
So if this is not a typo in the posting you should send:

Code: Select all

char arrReport[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; 
unsigned long intReturn; 
 
 arrReport[0] = 0x20; // or if you want to stay with decimals its 32
intReturn = IowKitWrite( hndIOW, 1, arrReport, sizeof(arrReport) ); 
The commandvalue you send (20=0x14) refers to a specialmode command (LedMatrix) that is not available on the PowerVampire.

So there could be 2 reasons why the write fails:
the software gets confused because of the invalid command for the chip
or
the chip itself gets on the wrong track on your command.

You should also set a timeout for the write-operation (IowKitSetWriteTimeout) use something small like 1000-5000ms. The default write-timeout is forever, so that might also be a reason your function nerver returns.

Eberhard
hytecinc
Posts: 9
Joined: Mon Jun 19, 2006 9:55 pm

Ya...

Post by hytecinc »

wayoda wrote: but all the values for specialmode-sequences that start with $ are Hex-values.
Ya, I tried it as hex also, same problem. The write never returns.
wayoda wrote: So there could be 2 reasons why the write fails:
the software gets confused because of the invalid command for the chip
or
the chip itself gets on the wrong track on your command.

You should also set a timeout for the write-operation (IowKitSetWriteTimeout) use something small like 1000-5000ms. The default write-timeout is forever, so that might also be a reason your function nerver returns.
I'll try adding a timeout to see if it gives me any more helpful information on the return.

I guess I don't know where to look next. Should I be verifying my schematic and wiring, or is this purely a software thing? We've already had to have all of our chips replaced with newer ones. Then we were given this Beta of the library to use.

Now I'm stuck again. I'm facing deadlines and am major league frustrated.

Thanks for the reply,

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

Post by Guido Körber »

No, this can not be a electrical problem, the status should be returned in any case as long as the chip is basically working (which it does if it shows up on the USB).

Have you used "SimpleHIDwrite" to manually send the stuff and look at the results? You can find it in the SDK in Samples/General HID Tools
hytecinc
Posts: 9
Joined: Mon Jun 19, 2006 9:55 pm

Post by hytecinc »

Guido Körber wrote:No, this can not be a electrical problem, the status should be returned in any case as long as the chip is basically working (which it does if it shows up on the USB).

Have you used "SimpleHIDwrite" to manually send the stuff and look at the results? You can find it in the SDK in Samples/General HID Tools
Yup, SimpleHidWrite works ok:

Code: Select all

W 20  00 00 00 00 00 00 00 
R 20  02 00 00 00 00 00 00
That's the response I would expect anyway.

Matt
hytecinc
Posts: 9
Joined: Mon Jun 19, 2006 9:55 pm

Alright, I am making progress...

Post by hytecinc »

I must be misunderstanding the documentation. I just tried doing a write to interface 0 with function 0x20 then chased it with a read on interface 0 and that works as advertised. Here is the bit from the manual:
5.7.4 Power status functions
IOW24PV has a function to read back the power
mode it has been configured for.
To read the power mode a report with ID $20 is
sent to interface 1:
This will return a report with ID $20 containing the
power mode:
mode = 1 is 100mA
mode = 2 is 500mA
From that I thought that A) I needed to write to interface 1 (the second parameters on the write) and that B), the buffer sent into the write function would be modified with the response. I didn't understand that I needed to do a follow up read.

Maybe just the docs need updating?

So here is my new code that works:

Code: Select all

AnsiString strReturn;
	char arrReport[MSG_LEN] = { 0, 0, 0, 0, 0, 0, 0, 0 };
	unsigned long intReturn;

	arrReport[0] = 0x20;

	if ( ! IowKitSetWriteTimeout( hndIOW, 1000 ) ) {
		memLog->Lines->Add( "Failed to set write timeout." );
	}
	else {
		intReturn = IowKitWrite( hndIOW, 0, arrReport, MSG_LEN );

		if ( intReturn != MSG_LEN ) {
			memLog->Lines->Add( "Failed to write to the IOW. Return = " + String( intReturn ) );
		}
		else {
			memLog->Lines->Add( "Write succeeded, reading response..." );

			intReturn = IowKitRead( hndIOW, 0, arrReport, MSG_LEN );

			if ( intReturn == MSG_LEN ) {
				for ( unsigned int i = 0; i < MSG_LEN; i++) {
					strReturn += String( (int)arrReport[i] ) + " ";
				}

				memLog->Lines->Add( "Response = " + strReturn );
			}
			else {
				memLog->Lines->Add( "The read failed." );
			}
		}
	}
And the output (the response is in decimal):

Code: Select all

IowKit Version IO-Warrior Kit V1.5
Opening Device...
Opened the device.
There is/are 1 device(s) connected.
Device #1
13697044: Is an unknown IOW (5394)
13697044: Revision 4131
13697044: Serial #00000224
Write succeeded, reading response...
Response = 32 2 0 0 0 0 0 0 
Now onto actually setting bits...

Matt
hytecinc
Posts: 9
Joined: Mon Jun 19, 2006 9:55 pm

Found a bug in your library.

Post by hytecinc »

So I decided to stop feeling around in the dark and just compiled your source directly into my test program.

I found that in the IowiFillInList function, your case statement is missing any reference to the IOWPV1 or 2.

Here's the original code:

Code: Select all

switch (hidAttr.ProductID)
       {
        case IOWKIT2_PID_IOW40:
	  n = (hidCaps.OutputReportByteLength == 5) ? IOWKIT2_PIPE_IO_PINS : IOWKIT2_PIPE_SPECIAL_MODE;
          break;
        case IOWKIT2_PID_IOW24:
	  n = (hidCaps.OutputReportByteLength == 3) ? IOWKIT2_PIPE_IO_PINS : IOWKIT2_PIPE_SPECIAL_MODE;
	  break;
	case IOWKIT2_PID_IOW56:
	  n = (hidCaps.OutputReportByteLength == 8) ? IOWKIT2_PIPE_IO_PINS : IOWKIT2_PIPE_SPECIAL_MODE;
	  break;
       }
I added in references to the PVs like so:

Code: Select all

switch (hidAttr.ProductID)
       {
	case IOWKIT2_PID_IOW40:
	  n = (hidCaps.OutputReportByteLength == 5) ? IOWKIT2_PIPE_IO_PINS : IOWKIT2_PIPE_SPECIAL_MODE;
	  break;
	case IOWKIT2_PID_IOW24:
	case IOWKIT2_PID_IOWPV1:
	case IOWKIT2_PID_IOWPV2:
	  n = (hidCaps.OutputReportByteLength == 3) ? IOWKIT2_PIPE_IO_PINS : IOWKIT2_PIPE_SPECIAL_MODE;
	  break;
	case IOWKIT2_PID_IOW56:
	  n = (hidCaps.OutputReportByteLength == 8) ? IOWKIT2_PIPE_IO_PINS : IOWKIT2_PIPE_SPECIAL_MODE;
	  break;
       }
With that modification, I can now access the power status on Pipe 1 and I/O pins on Pipe 0. I'm going to compile this up as a static lib and use it for my application.

Hope that helps fix the lib for a final release. Thanks,

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

Post by Guido Körber »

Thank you for that input. I will forward this to the responsible programmer, though he is sick at the moment, which is the reason for our slow response to this topic.
Post Reply