Developing a GUI application

Discuss Sugar, upgrades and developer perspectives.

Re: Developing a GUI application

Postby yuvvrajsingh » Sun Apr 12, 2009 4:45 am

Basically it a software supported by usb.org
yuvvrajsingh
 
Posts: 54
Joined: Sun Jan 25, 2009 3:30 am

Re: Developing a GUI application

Postby yuvvrajsingh » Sun Apr 12, 2009 4:48 am

Nope ...the same erroorrr again
:roll:
yuvvrajsingh
 
Posts: 54
Joined: Sun Jan 25, 2009 3:30 am

Re: Developing a GUI application

Postby cuprum » Sun Apr 12, 2009 4:52 am

I have never done anything like this, but I'll post anyways.

Are we sure the device takes input in ASCII, and not binary?

There are also issues with line endings and whether python will write anything before the file is closed.

The error message you posted said the error was on "close", which does not mean the write failed.
cuprum
 
Posts: 87
Joined: Fri Mar 28, 2008 5:34 am

Re: Developing a GUI application

Postby yuvvrajsingh » Sun Apr 12, 2009 4:55 am

http://profmason.com/?cat=5&paged=2

A link showing the SimpleHIDWrite at work In Windows
Hope this helps
yuvvrajsingh
 
Posts: 54
Joined: Sun Jan 25, 2009 3:30 am

Re: Developing a GUI application

Postby yuvvrajsingh » Sun Apr 12, 2009 4:57 am

As ektoric told....it works fine with ordinary file write( removing the location /dev/usb/hiddev0)
So logically it shud work out rite ????
yuvvrajsingh
 
Posts: 54
Joined: Sun Jan 25, 2009 3:30 am

Re: Developing a GUI application

Postby yuvvrajsingh » Sun Apr 12, 2009 5:09 am

You dont send teh data alone..
You got to send some report ID ...But i dont know how to send
I dont know the rpoblem is whether with the write(format) or soem unknown format in whcih i have to enter the data

If anyone knows pls help out.....it wud be really great !!!
yuvvrajsingh
 
Posts: 54
Joined: Sun Jan 25, 2009 3:30 am

Re: Developing a GUI application

Postby cuprum » Sun Apr 12, 2009 5:20 am

What got written to the file was the ascii codes for the numbers 0 and 2. The fact that you could read them without converting them back is actually a bad sign. Remember reading values from the thermometer?

I went to the profmason site but was unable to make sense of it; I do not know Visual Basic.
cuprum
 
Posts: 87
Joined: Fri Mar 28, 2008 5:34 am

Re: Developing a GUI application

Postby yuvvrajsingh » Sun Apr 12, 2009 5:39 am

The page was just to show how the software in XP works out'SImple HID write'
YOu type values in the fields and you press Write
the value gets written.... Thats how it works in XP
yuvvrajsingh
 
Posts: 54
Joined: Sun Jan 25, 2009 3:30 am

Re: Developing a GUI application

Postby yuvvrajsingh » Sun Apr 12, 2009 7:38 am

somebody pls helppp :roll:
yuvvrajsingh
 
Posts: 54
Joined: Sun Jan 25, 2009 3:30 am

Re: Developing a GUI application

Postby cuprum » Sun Apr 12, 2009 10:26 am

yuvvrajsingh wrote:somebody pls helppp :roll:

Sorry yuvvrajsingh, what you are doing is well beyond my experience. What might help are people who have used Linux with same microcontroller model you have. I have never used any microcontroller, nor do I know enough Linux to write device drivers.

I did find this link. http://www.kernel.org/doc/Documentation/usb/hiddev.txt. If I understand what is written there, ektoric is right, you can not write to that file. If there is a file somewhere else, with a high level interface, I would not know about it.

Good luck.
cuprum
 
Posts: 87
Joined: Fri Mar 28, 2008 5:34 am

Re: Developing a GUI application

Postby ektoric » Sun Apr 12, 2009 11:15 am

yuvvrajsingh wrote:You dont send teh data alone..
You got to send some report ID ...But i dont know how to send
I dont know the rpoblem is whether with the write(format) or soem unknown format in whcih i have to enter the data

I think here's the problem. As said waaaaay back on page 1, you're going to need a driver to talk to your device. And if you don't have one, you're going to have to write one. The USB-HID api "simplifies" driver development, but it's simpler relative to writing a USB driver. It's still not as simple as reading bits out and stuffing bits in.

Check out http://www.kernel.org/doc/Documentation/usb/hiddev.txt and you can see that to read from an HID device, you can read events by a simple file read (and aligning the bytes to an events struct). You did this way back on page one as well:
Code: Select all
00014200 01 00 00 ff 79 00 00 00 02 00 00 ff 01 00 00 00 |....y...........|
00014210 01 00 00 ff 7a 00 00 00 02 00 00 ff 01 00 00 00 |....z...........|
00014220 01 00 00 ff 77 00 00 00 02 00 00 ff 01 00 00 00 |....w...........|
00014230 01 00 00 ff 72 00 00 00 02 00 00 ff 01 00 00 00 |....r...........|

Those byte sequences can be ligned up with the hiddev_event struct
Code: Select all
       struct hiddev_event {
           unsigned hid;
           signed int value;
       };

Resulting in:
Event 1:
* hid usage page: 0xff00
* hid usage code: 0x0001
* value: 0x0000007a
Event 2:
* hid usage page: 0xff00
* hid usage code: 0x0002
* value: 0x00000001
And interpreting all of that depends on your device.

But writing to the HID interface will be a little more challenging. You'll need to understand how to construct HID reports.

I say all of this from googling different combinations of keywords including: linux, usb, hid, write. In other words, I have never written to a HID-dev interface! So my apologies for not stopping you from going down the wrong track.

I also found http://libhid.alioth.debian.org/ which includes python bindings (in other words, it's a C library, but you can call it from python function calls).

But at the end of the day, you are currently way beyond OLPC and strongly into USB land. Consider asking your USB development questions on the linux usb mailing list http://www.linux-usb.org/mailing.html or join the IRC channel (info also provided on that link). Those guys should be able to help, or direct you to the right place to get driver help.

Edit: woops! cuprum beat me to the punch with the informative link! :)
ektoric
Support Team
 
Posts: 470
Joined: Wed Jan 02, 2008 3:46 pm
Location: Austin, TX

Re: Developing a GUI application

Postby cuprum » Sun Apr 12, 2009 8:34 pm

cuprum wrote:
I did find this link. http://www.kernel.org/doc/Documentation/usb/hiddev.txt. If I understand what is written there, ektoric is right, you can not write to that file.


I could easily be wrong about this. EINVAL (Invalid Argument) is returned by hiddev.c for many different errors, including badly-formed reports. So when close() is called by your python script exiting, it sends "02" to the hiddev driver, which rejects it as invalid.

That is only a theory. It does seem the documentation wants you to call ioctl(), not write.
cuprum
 
Posts: 87
Joined: Fri Mar 28, 2008 5:34 am

Re: Developing a GUI application

Postby yuvvrajsingh » Tue Apr 14, 2009 1:22 am

I have uploaded a screenshot of the software simplehidwrite in work
It shud be noted that unless the report id is 00 it gives an error.
The microcontroller is designed so that you can pass the location of the EEPROM and the value to be written to it in the 2nd row .
so for the example above i tried it write the value 00(2ND ENTRY 2ND ROW) to the EEPROM location 00 (1st ENTRY 2ND ROW)

http://drop.io/yuvvrajsingh

What im unaware is how to write these values in LINUX... my best guess is the values we are writing now in XP are HEX values...

If aneone has any ideas pls share....im waiting

For Ektoric, i read through the hiddev0 doc link you had posted ..... but i couldn't figure out what is wRONG with the current operation
yuvvrajsingh
 
Posts: 54
Joined: Sun Jan 25, 2009 3:30 am

Re: Developing a GUI application

Postby cuprum » Tue Apr 14, 2009 9:23 pm

I don't know enough to help create the report. SimpleHIDWrite is not a simple program.

I just found there is a python module called "struct" which lets you turn python variables into C structures.

The function is "struct.pack".
Code: Select all
import struct
a= 65
b= -10

# an integer and a short
d=struct.pack("ih",a,b)
cuprum
 
Posts: 87
Joined: Fri Mar 28, 2008 5:34 am

Re: Developing a GUI application

Postby yuvvrajsingh » Tue Apr 14, 2009 10:23 pm

hi cuprum...
can you be more clear on how the struct module can be used to serve our MAIN PURPOSE of writing back ???
HELP is always appreciated
yuvvrajsingh
 
Posts: 54
Joined: Sun Jan 25, 2009 3:30 am

PreviousNext

Return to Sugar, Linux and System Software

Who is online

Users browsing this forum: No registered users and 1 guest

cron