CodeMercs Forum

Code Mercenaries Hard- und Software GmbH Webboard
Aktuelle Zeit: Mo Sep 06, 2010 1:10 pm

Alle Zeiten sind UTC + 1 Stunde [ Sommerzeit ]




Ein neues Thema erstellen Auf das Thema antworten  [ 14 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: IowKitWrite
BeitragVerfasst: Do Jul 15, 2010 10:05 am 
Offline

Registriert: Fr Jul 09, 2010 11:15 am
Beiträge: 10
I am having trouble trying to write to a device, i tried using the example in the Help Doc-

Code:
   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:
        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


Nach oben
 Profil  
 
 Betreff des Beitrags: Re: IowKitWrite
BeitragVerfasst: Do Jul 15, 2010 10:23 am 
Offline
Site Admin

Registriert: Di Nov 25, 2003 10:25 pm
Beiträge: 2616
Wohnort: Germany/Berlin
What are you trying to do?

You are writing to the second interface, and you are specifying the report length for the first interface.


Nach oben
 Profil  
 
 Betreff des Beitrags: Re: IowKitWrite
BeitragVerfasst: Do Jul 15, 2010 11:06 am 
Offline

Registriert: Fr Jul 09, 2010 11:15 am
Beiträge: 10
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)


Nach oben
 Profil  
 
 Betreff des Beitrags: Re: IowKitWrite
BeitragVerfasst: Do Jul 15, 2010 11:16 am 
Offline

Registriert: So Okt 08, 2006 3:43 pm
Beiträge: 224
Wohnort: Germany / Berlin
Type this:

Code:

   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
------------------------------------
Es gibt für jedes Problem eine Lösung....Nur für meine nicht...


Nach oben
 Profil  
 
 Betreff des Beitrags: Re: IowKitWrite
BeitragVerfasst: Do Jul 15, 2010 11:32 am 
Offline

Registriert: Fr Jul 09, 2010 11:15 am
Beiträge: 10
It compiles with this but still nothing happening.


Nach oben
 Profil  
 
 Betreff des Beitrags: Re: IowKitWrite
BeitragVerfasst: Do Jul 15, 2010 11:40 am 
Offline

Registriert: So Okt 08, 2006 3:43 pm
Beiträge: 224
Wohnort: Germany / Berlin
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
------------------------------------
Es gibt für jedes Problem eine Lösung....Nur für meine nicht...


Nach oben
 Profil  
 
 Betreff des Beitrags: Re: IowKitWrite
BeitragVerfasst: Do Jul 15, 2010 12:22 pm 
Offline

Registriert: Fr Jul 09, 2010 11:15 am
Beiträge: 10
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:
                       
report.ReportID = 0x02;
report.Bytes[0] = 0xC1 + send;
report.Bytes[1] = adresse;


Nach oben
 Profil  
 
 Betreff des Beitrags: Re: IowKitWrite
BeitragVerfasst: Do Jul 15, 2010 12:43 pm 
Offline

Registriert: So Okt 08, 2006 3:43 pm
Beiträge: 224
Wohnort: Germany / Berlin
I cannot follow you. What will you do with your programm?
Will you use the IO-Pins or the Special mode?

_________________
Abteilung: Softwareentwicklung
------------------------------------
Es gibt für jedes Problem eine Lösung....Nur für meine nicht...


Nach oben
 Profil  
 
 Betreff des Beitrags: Re: IowKitWrite
BeitragVerfasst: Do Jul 15, 2010 12:57 pm 
Offline
Site Admin

Registriert: Di Nov 25, 2003 10:25 pm
Beiträge: 2616
Wohnort: Germany/Berlin
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.


Nach oben
 Profil  
 
 Betreff des Beitrags: Re: IowKitWrite
BeitragVerfasst: Do Jul 15, 2010 1:00 pm 
Offline

Registriert: Fr Jul 09, 2010 11:15 am
Beiträge: 10
After tracing through the source code for Simple-IIC i got it work with this code:
Code:
      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:
      report.ReportID = 2;
      report.Bytes[0] = 196;
      report.Bytes[1] = 80;


Thanks for all your help so far.


Nach oben
 Profil  
 
 Betreff des Beitrags: Re: IowKitWrite
BeitragVerfasst: Do Jul 15, 2010 1:05 pm 
Offline

Registriert: So Okt 08, 2006 3:43 pm
Beiträge: 224
Wohnort: Germany / Berlin
This code is for use the IIC Interface NOT for the SimpleIO. Take a look into the SimpleIO sample into the SDK.

_________________
Abteilung: Softwareentwicklung
------------------------------------
Es gibt für jedes Problem eine Lösung....Nur für meine nicht...


Nach oben
 Profil  
 
 Betreff des Beitrags: Re: IowKitWrite
BeitragVerfasst: Do Jul 15, 2010 1:08 pm 
Offline
Site Admin

Registriert: Di Nov 25, 2003 10:25 pm
Beiträge: 2616
Wohnort: Germany/Berlin
Please have a look at the documentation. The IO-Warrior Datasheet contains the specification of the functions.


Nach oben
 Profil  
 
 Betreff des Beitrags: Re: IowKitWrite
BeitragVerfasst: Di Jul 20, 2010 4:45 pm 
Offline

Registriert: Fr Jul 09, 2010 11:15 am
Beiträge: 10
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:
for(int i = 0; i < 255; i++)
     {
       Write(ioHandle,40,1,i);
      cout << i << endl;
      Sleep(20);
     }



Code:
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
....


Nach oben
 Profil  
 
 Betreff des Beitrags: Re: IowKitWrite
BeitragVerfasst: Di Jul 20, 2010 5:32 pm 
Offline
Site Admin

Registriert: Di Nov 25, 2003 10:25 pm
Beiträge: 2616
Wohnort: Germany/Berlin
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.


Nach oben
 Profil  
 
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 14 Beiträge ] 

Alle Zeiten sind UTC + 1 Stunde [ Sommerzeit ]


Wer ist online?

Mitglieder in diesem Forum: Yahoo [Bot] und 1 Gast


Sie dürfen keine neuen Themen in diesem Forum erstellen.
Sie dürfen keine Antworten zu Themen in diesem Forum erstellen.
Sie dürfen Ihre Beiträge in diesem Forum nicht ändern.
Sie dürfen Ihre Beiträge in diesem Forum nicht löschen.
Sie dürfen keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Deutsche Übersetzung durch phpBB.de