Developing a GUI application

Discuss Sugar, upgrades and developer perspectives.

Developing a GUI application

Postby nevinalexolpc » Thu Jan 01, 2009 8:12 am

I want to develop a GUI application on the X0 which can be used to display data (room temperature)
The data is send from teh sensor via U.S.B
How can i access the data from U.S.B from terminal directly??
Does python aid in GUI programming???
Does XO have python with GTK ???
If anybody has refernces to good ebooks that can help me in developing the application...pls reply
nevinalexolpc
 
Posts: 1
Joined: Thu Jan 01, 2009 7:51 am

Re: Developing a GUI application

Postby ncarrol » Thu Jan 01, 2009 11:23 am

ncarrol
 
Posts: 367
Joined: Mon Aug 25, 2008 12:38 am

Re: Developing a GUI application

Postby yuvvrajsingh » Sun Jan 25, 2009 4:19 am

Thats the case when data is coming form analog port..........
How to access data that comes via USB port ???
Can anyone help me build a python GUI that can print the data from USB (configured as HID) onto GUI window based on gtk

how to access a device that is configured as a HID(human interface device)

/proc/bus/usb/devices

But where is the data ???

How can i write it to a file ?????


How to copy an image from the Measure oscilloscope to a GUI window suign python ??
Where is the log image of the OSCILLOSCOPE beign saved ??
yuvvrajsingh
 
Posts: 54
Joined: Sun Jan 25, 2009 3:30 am

Re: Developing a GUI application

Postby Freemor » Sun Jan 25, 2009 10:11 am

For getting the data you first have to determine where the usb device you want to read from is mounted. It'll almost certianly be in the /dev/.. tree. As far as I know the /proc/ tree doesn't provide device I/O.

For writing files in sugar/python:

see http://wiki.laptop.org/go/Sugar.activity.activity section 1.2 on how to determine diretories your activity can safely sstore files in.

or to use the journal see:

http://wiki.laptop.org/go/Sugar.datastore.datastore

as far as capturing the output from measue probably the simplest wy would be to use alt-1 to take screen shots.

Setting up a Activities Canvas is a bit more the I'd be useful to help you with as I am just getting into Sugar/pyGTK myself.

Hope some of this helps.
Freemor
 
Posts: 30
Joined: Mon Dec 22, 2008 11:15 am
Location: New Brunswick, Canada

Re: Developing a GUI application

Postby yuvvrajsingh » Sun Jan 25, 2009 10:34 am

IS THEREany command using python through which i can constantly take pictures of the Measure window(something like polling every 1 sec) and then display on a GTK window.........IT shud run on its on....gather the information and disaply it......CONTINOUSLY

regarding the location....i realy realy dont know...where the actual file of the HID is located....Im really new to linux...i have being trying to figure out this thing for the past one month....and i am losing patience......all i know i s wheni attach HID ....CHANGES do occur in

/dev/input

proc/bus/usb

How to read the data....i really really dont know...
can anyone help me plssssssssssssssssssssssss
yuvvrajsingh
 
Posts: 54
Joined: Sun Jan 25, 2009 3:30 am

Re: Developing a GUI application

Postby yuvvrajsingh » Sun Jan 25, 2009 10:55 am

Free mor..i dont know...where to start ..the links you gave are gud..but i am really confused............
SEE...i am sending the temperature data via PIC to the OLPC via USB/// i need to access this temperature (the digitised value)
How do you do it ...can rite in simpler terms than this...
yuvvrajsingh
 
Posts: 54
Joined: Sun Jan 25, 2009 3:30 am

Re: Developing a GUI application

Postby ektoric » Tue Jan 27, 2009 11:50 am

wow.. um... huh?

Reading from the first few posts that were still intelligible, I think I want to do a little software engineering. You probably want to split this up into little chunks. At the very least split up the "how to get the data" component from the "how to display the data" part.

So, what kind of hardware do you have? What is the USB temperature device you have? Does it have a USB driver? If it doesn't have a USB driver, you may need to write an actual USB driver. Googling "how to write linux usb driver" yields some interesting links.

On the other hand, I'll gander a guess that it probably piggybacks on USB for transport, but its probably outputting its data in ASCII on some serial port. See your product manufacturer, and/or google the part number to see if anyone else has had any experience with it. There may already be a USB to serial driver for your chip readily available.

In either case, hopefully you'll have a /dev/ttySN (where N is some number) that you can hook up something as simple as minicom to see the output (be sure to check the baud rate!) These should be the numbers you are looking for, from a "data gathering component" perspective.

After you've "got the raw data", then you can think about how to present this data as an Activity. Freemor and ncarrol have provided some excellent resources on how to do an Activity.
ektoric
Support Team
 
Posts: 470
Joined: Wed Jan 02, 2008 3:46 pm
Location: Austin, TX

Re: Developing a GUI application

Postby yuvvrajsingh » Wed Jan 28, 2009 1:43 am

Thanks for replying,....

But i dont understand the need for writng a linux driver..???
The whole project goes something like this
The temperature sensor say LM35 sends voltage variations that are digitised by the micorcontoller using ADC.... and this digital value is being send to the PC via USB..

Since the device is microcontroller is programmed as a HID device....it just sends the data (digitised )to the USB link....so why need a extra driver ??

actully the device is detected corretly

/dev/usb/hiddev0

but how to read this file ???

i tried the same in ubunut b4 trying in OLPC...

cat hiddev0

it gave garbage values......but the thin is working...thats for sure..since the garbage values are continously outputted to the terminal....

How should i proceed ??

SUGGESTION ALYWAYS welcome

YUVVRAJSINGH
yuvvrajsingh
 
Posts: 54
Joined: Sun Jan 25, 2009 3:30 am

Re: Developing a GUI application

Postby Freemor » Wed Jan 28, 2009 10:27 am

ok so we now know that you can see and read from the device. good
what you next need to figure out is in what format thedevice is seending the data. From what you have described the continious line of garbage charactes it sounds like it is sending it is as a straight binary value. What we don't know is if it is a single byte per sample, or a word per sample, signed or unsigned.. I'd suggeest running a few tests with commands like:

hexdump -C /dev/hiddev0

this will display the bytes in both hex and ascii and you should be able to descern the pattern (i.e. if it is 32 degrees outside and you see a bunch of hex 20's you know it is sending the temp as a pre adjusted hex vaule.) unfortunately from the set-up you describe I wouldn't be surprised if what is comming in is just a value of the resistance measured in the sensor by the ADC. if that is the case you will have to run some tests (using different known temperatures) and figure out the math to apply to the input. might be a simple as subtracting X to get it to read 0 at 0 degrees or you may have to put in a bit more to get it to scale properly (i.e. subtracting x may make 0 read 0 but you may need to multiply/devide/otherwise adjust the reading so 30c reads 30c).

hope this helps
Freemor
Freemor
 
Posts: 30
Joined: Mon Dec 22, 2008 11:15 am
Location: New Brunswick, Canada

Re: Developing a GUI application

Postby yuvvrajsingh » Wed Jan 28, 2009 11:58 am

hey...finally it worked !!!!!!!!!!!!!!

Tahnksssssssszalott..

this is the ouput

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

As i changed the pot values the value changed as above..now i got to figure out by how much it varied.....

So i think its logical that the values that keep changing are the digitised values rite ????

Which is the ASCII value and the HEX value ???

Are the 79,7a,77,72 ASCII or Hex ??

Since i used Hex dump shouldnt it be HEX VALUES ???

yuvvrajsingh
yuvvrajsingh
 
Posts: 54
Joined: Sun Jan 25, 2009 3:30 am

Re: Developing a GUI application

Postby Freemor » Wed Jan 28, 2009 12:17 pm

In the hexdump readout the 00 ff 00 79 02 00 00 etc stuff is he hexidecimal values of the bytes coming in. The stuff on the right ..y... etc are the same bytes in ascii

Now that you can read see the data coming in you can figure out how to scale it to match the temperature. There is a clear pattern to the data which should make it easy to work with. Hopefully If someone here is more familiar with drvice I/O then I they may even recognize the pattern and be able to tell you what the other bytes are.

I'm glad you are now able to see the data and how itis formatted. going from here to a working program shouldn't be too much work.

Later,
Freemor
Freemor
 
Posts: 30
Joined: Mon Dec 22, 2008 11:15 am
Location: New Brunswick, Canada

Re: Developing a GUI application

Postby yuvvrajsingh » Wed Jan 28, 2009 2:26 pm

which is the most advisable method to build a GUI based on this ?

Writing the data from terminal to a file and process the text to find the temperature and then disaply accordingly ??

Or use pyUSB (which i have absolutely no idea of) Most of the websites suggest using PyUSB ....

aNYBODY has any suggestions ..or Idea on PYUSB

is py usb module in OLPC basic version XO ??

has anyone tried python programming with Pyusb in OLPC ????

YUVVRAJ
yuvvrajsingh
 
Posts: 54
Joined: Sun Jan 25, 2009 3:30 am

Re: Developing a GUI application

Postby Freemor » Wed Jan 28, 2009 9:59 pm

There is a project the look quite similar to what you are wanting to so (in python, but not on the OX, and their Temp hardware shows up as /dev/ttyUSBx) but you should be able to look at the code and get some ideas of how to proceed..

it is at:

http://programming.arantius.com/pytempe ... -in-python

and another one here (tho the source is C and Python mixed)

http://www.digitemp.com/software.shtml

you can study those but how your Temperature device works may be different. You might want to google the model /brand of your temp device and python (i.e. google: +ut300 +python If your device was a ut300). if someone has already done the bulk of the work you are looking for and open sourced it modifying their code to fit your need (adapting it to Sugar) might be a less daunting project.

Hope this Helps
Freemor
 
Posts: 30
Joined: Mon Dec 22, 2008 11:15 am
Location: New Brunswick, Canada

Re: Developing a GUI application

Postby yuvvrajsingh » Thu Jan 29, 2009 5:39 am

Thanks for the information ///

Are there any good e-books/TUTORIALS available on "Application Development in SUGAR environment " ...........

YUVVRAJSINGH
yuvvrajsingh
 
Posts: 54
Joined: Sun Jan 25, 2009 3:30 am

Re: Developing a GUI application

Postby Freemor » Thu Jan 29, 2009 3:19 pm

There is a lot of information on http://wiki.laptop.org . It took me a while to find the bits I needed but I'm making slow progress on my own first activity.

I found the "Hello World" tutorial to be a good starting place.

http://wiki.laptop.org/go/Activity_tutorial

and actually started out with the hello world activity and just modified it into what I want.
The PyGTK documentation at:

http://www.pygtk.org/tutorial.html

To be useful for understanding hboxes and Vboxes and the like.

Regards,
Freemor
Freemor
 
Posts: 30
Joined: Mon Dec 22, 2008 11:15 am
Location: New Brunswick, Canada

Next

Return to Sugar, Linux and System Software

Who is online

Users browsing this forum: No registered users and 2 guests