Wednesday, 2014-06-25

*** Merbot has joined #sailfishos-porters17:07
lbtStskeeps: ^17:09
tbrlet me de-uglify that17:16
*** Aquilum has quit IRC17:19
*** Aquilum has joined #sailfishos-porters17:24
lbttbr: ty17:25
lbttbr: I added me as a bot owner too - just fyi17:25
lbt ?17:26
lbtoh - wait17:26
lbtthat one is crap17:26
lbtit clones repos and polls them :)17:26
lbtnm ... -> tango o/17:27
vgradelbt: tbr thanks18:04
netchipMSameer: that doesn't work18:25
netchipMSameer: because I have to pass a hardware_device_t to open()18:25
MSameernetchip: cast it18:29
netchipMSameer: doesn't work18:30
MSameerwhat's the error?18:30
MSameerand show me the code :)18:30
netchipmer_camera.cpp:24:11: error: 'camera_device_t' has no member named 'close' :P18:30
netchipeasy fix18:30
MSameercamera_device_t *dev;18:31
netchipderp thing18:32
MSameerwhere is the close...18:32
MSameerhw_device_t has it18:33
netchipmeh, fixed it, I hope18:33
netchiphw_get_module worries me18:33
netchipbecause it assumes it18:33
netchipit gets a hw_device_t18:34
netchipand a hw_device_t doesn't inherit camera_device_t18:34
netchipinversed, I mean18:34
MSameerbbl child18:34
situsledges: around ?18:40
MSameernetchip: don't be worried as long as it works18:49
MSameernetchip: the other explanation is: you are casting a subclass (camera_device_t) to a superclass (hw_device_t) which should work18:49
sledgessitu: yepish19:04
situsledges: So what do we need to check ?19:05
sledgesrestore debugfs systemd files, reboot; systemctl --user stop lipstick.service, strace -fF `the pid of the systemd --user` -- and past the output for us after executing `systemctl --user start lipstick.service` in another window19:06
sledgessitu: ^19:06
netchipMSameer: get_parameters works19:07
netchipdo we have logging, btw??19:07
netchipI don't want to log to stdout19:07
MSameeryou can log to stderr19:07
MSameerand redirect it to a file19:07
MSameer./test 2> foo.log19:08
MSameeror even to /dev/null19:08
netchipMSameer: How do I do that with cout? :P And I heard sledges talk anout journalctl?19:08
MSameernetchip: std::cerr :)19:08
MSameernetchip: I don't know how to log to journalctl19:08
netchipOh OK19:08
netchipI want something like Android's ALOGV19:09
netchipand ALOGI19:09
netchipworks perfectly19:09
MSameerviewing logs via logcat is easier than stdout?!19:10
MSameer#include <syslog.h>19:10
netchipMSameer: I don't want my stdout to be cluttered with things like "called put_parameters" :P19:11
MSameernetchip: are you on linux?19:11
MSameerman syslog19:11
situsledges: Good site for long pastes ?19:12
netchipMSameer: where does that output to?19:13
MSameersitu: is not enough?19:13
MSameernetchip: to syslog and I think that goes to journalctl19:13
situMSameer: I have seen problems with pastebin some time back.19:13
MSameernetchip: but I really don't know19:13
netchipThe option argument to openlog() is an OR of any of these what's an OR?19:14
MSameernetchip: one or more separated with |19:15
netchipoh it's a binary thingy?19:15
MSameeryup :)19:16
netchipI've always wanted to know how exactly that works19:16
netchipI can count in the binary system19:16
netchipbut no clue how the binary operators work19:16
MSameernetchip: easy19:16
MSameer001 | 010 gives you 01119:17
MSameer001 & 011 gives 00119:17
MSameer^ <- I always forget that19:17
netchiphow does the program interpret that?19:17
MSameerit tests the various bits19:18
MSameerif (011 & 001) { print("001 is set") }19:18
MSameerI think that's the basic thing19:18
netchip& is the thing in common19:18
netchip| is the thing added together (basically)?19:19
MSameernetchip: it's the binary AND operator19:19
MSameer| is the OR operator19:19
MSameer& is the AND19:19
situsledges: Still around ?19:20
*** slate has quit IRC19:20
netchipMSameer: I'll read it in a bit :)19:21
MSameernetchip: I think now I started to understand ^ operator19:21
MSameernetchip: thanks for pointing me indirectly to that article :)19:21
* MSameer learned something new \o/ :D19:21
netchipnext week I have two projectdays @ school about sustainable energy19:23
netchipit's interesting19:23
MSameerwhat are you studying ?19:23
MSameer(if I may ask)19:23
netchipHehe, middleschool (European equivalent of highschool), 15 years old19:24
netchip3rd form, going to the 4th form19:24
netchip(of the 6th forms)19:24
MSameerI know you are 15 years old :)19:24
netchipof the six forms*19:24
MSameerbu I thought that a project would be at collage so I was confused19:25
* MSameer slaps himself19:25
situI feel like I should have started programming much earrlier.19:25
netchipwe have a lot of projects19:25
MSameernetchip: +1 :)19:25
netchipsitu: So do I, lol. But hey, I didn't understand it years ago.19:25
netchipMaths education helped :)19:25
MSameeryou need discreet math19:26
situnetchip: You should read this book when you get time
MSameeror that's what I heard :P19:26
MSameerwhen I was 15, I think I didn't have a computer of my own19:27
MSameernetchip: and grab a copy of the C++ programming language19:27
netchipI have The C Programming language here19:28
netchipbut despite of the good reviews, I find it to be a poor book19:28
MSameernetchip: that's is fine. don't read it if you don't like it19:28
MSameerI don't remember I have ever read a book fully19:28
netchipit's too simple19:28
netchiptoo superficial19:28
situnetchip: What do you think is missing from that book ?19:28
MSameernetchip: I hope you don't feel offended but based on working with you for ~2 days, your C/C++ knowledge is superficial too19:29
netchipMSameer: I know it is ;)19:29
netchipand I don't feel offended19:29
netchipsitu: it explains every bit of C, yes. But it misses good examples19:29
MSameernetchip: so we need to find you a good book or set of tutorials to get you started (assuming it's what you want)19:29
MSameernetchip: bypass the bad chapters19:30
MSameerexamples? you are seeing them now :D19:30
MSameernetchip: then try thinking in C++19:30
*** slate has joined #sailfishos-porters19:30
MSameersomething I liked was diving into python. it starts with an example but it's python19:31
netchipI learned Java mostly by doing :) I think C++ is less of a learn-by-doing-language19:31
netchipand I think I'll download thinking in C++ if it's available as epub19:32
netchipthose books are often expensive19:32
situnetchip: It's available in ebook form.19:32
netchipI don't see it on a very popular torrent site :p I mean, 75EUR for two books is much money19:33
netchipthinking in problems: how mathematics find creative solutions, looks interesting19:34
situThe links to download were there on that page itself.19:35
netchipI see19:39
MSameernetchip: you learn programming really by doing19:39
MSameerone of the reasons why my java is very rusty is I never had to use it for anything19:39
MSameernetchip: but for C++, you need some concepts and you are good to go19:39
MSameerpointers are also *(&(&*^&*%&*19:39
MSameernetchip: wouldn't using cameraservce directly make your life easier wrt camera?19:40
netchipI don't know :) But I like this approach :P I think I learn more doing it this way, but if you think using cameraservice is better for me to learn C++, sure. I'll do the cameraservice way then.19:41
MSameeri have to admit that I don't know :)19:42
MSameerperhaps a good way is to get an idea of all chapters then map the practical part we are doing now to the relevant chapter of the book?19:43
netchipthe syntax of C++ isn't my problem; the problem is more: when can I cast this to that, what are the restrictions of pointers, what are smartpointers etc19:43
MSameercasting in our context is simple19:44
MSameera class A that inherits another class B19:45
MSameerB is the parent class or superclass19:45
MSameerA is subclass19:45
MSameerand in general, you can cast a subclass to a super class (or a parent class)19:45
MSameerbut C++ has more casting details19:46
netchipI don't see how camera_device_t inherits hw_device_t. Sure, the name implies it. However, I don't see it code-wise19:46
MSameerbecause this is C19:47
MSameerthe first member of camera_device_t is     hw_device_t common;19:47
netchipwhy do we cast camera_device_t to hw_device_t, then?19:48
netchipit only contains a structure called hw_device_t19:48
MSameernetchip: it contains more19:48
MSameer    camera_device_ops_t *ops;19:48
MSameer    void *priv;19:48
MSameernetchip: i have an idea for you: go to codeaurora and check the forst qualcomm camera hal19:49
netchipMSameer: I did :) That's how I fixed the open() problem19:49
MSameerlet me try to find a good example for you19:50
netchipthe derivation of structures in C is ... illogical19:50
netchipor unlogical or whatever19:51
netchipI associate inheritance with OOP19:51
MSameernetchip: it's confusing because it's not logical and I agree :)19:53
netchiphow comes the : is possible?19:54
MSameerbut I think it works because it has something to do with how it's stored in memory19:54
MSameerit assigns19:55
MSameergcc extension IIRC19:55
MSameerline 74 is the struct you get via hw_get_module19:55
MSameerso it is camera_module_t19:55
MSameerand this is why you need to pass camera_module_t * and not hw_module_t19:55
* MSameer food19:55
MSameernetchip: here is what gets assigned to your pointer:
netchipMSameer: oh, so a camera_device is casted to a hw_device20:39
MSameerit's the address of common which is the first member20:43
MSameernetchip: here is an example:
MSameernetchip: it prints the address of the struct and the address of the first element20:47
MSameerand note they are the same20:48
MSameerbar = 0x8644008, foo = 0x864400820:48
MSameerso we can do: Bar *b2 = (Bar *)f;20:49
MSameerand it will still work20:49
netchiphmm yeah21:02
netchipit's complicated21:02
MSameerno it's not21:10
MSameernetchip: you see it a the programmer sees it21:11
MSameernetchip: but when the app gets executed and the struct start to be assigned to a memory address then it's just bytes following bytes21:11
netchipMSameer: well, it makes sense21:11
MSameerthere is no such thing as a struct inside a struct in RAM because RAM does not know21:11
MSameerthose 4 bytes are reserved for the int and then another 4 for the next int21:12
MSameerwhether it's inside another struct or not does not make a difference21:12
MSameernetchip: do you know that the address to an array of chars is the address of the first element?21:12
MSameerthis is the same :)21:13
netchipquestion: Foo *f = &b->foo;21:13
netchipwhy &b?21:13
MSameerbecause we need an address21:13
netchipthat's the adress of the pointer right?21:13
MSameerFoo *f is a pointer21:13
MSameerb->foo is the element itself21:13
MSameerand the element is of a type Foo21:13
MSameerpointers are confusing21:14
netchipI see it now21:14
MSameerso if we have:21:14
MSameerstruct Foo { int bar; char zot; }21:15
MSameerand if address of Foo is 0x4 for example21:15
MSameerthen 0x4 is also the address of bar21:16
MSameerand 0x8 is the address of zot21:16
MSameerassuming int is 4 bytes long (32 bit integer)21:16
MSameerbut don't just add offsets to the struct like that because it will blow up in real world :)21:17
netchipand that's how it's possible to cast it...21:28
*** hexo has joined #sailfishos-porters21:28
netchipit became clearer21:31
netchipit's still blackmagic, but it's enoguh to use it :)21:31
MSameerwell, then you need to start asking more concrete questions21:32
MSameerI don't know how to explain it farther :/21:32
netchipMSameer: don't feel bad about it21:35
netchipthe blackmagic thing is21:35
netchipMSameer: how would three and four get filled if barvariable = (foo) foovariable21:39
MSameerthey don't21:41
MSameerthey are garbage21:41
MSameerbut in our case, camera_device_t gets casted to hw_device_t21:41
MSameeractually, if you doo:21:41
MSameerfoo *f = malloc(sizeof(foo));21:42
MSameerand then did bar *b = (bar *) f;21:42
MSameerthen if you try to write to b->three; then you will crash21:42
MSameerbecause that memory does not belong to you21:42
MSameeryou might crash21:43
netchipMSameer: how would ops be useful then21:49
netchip(member of camera_device_t_21:49
netchipbecause we give the pointer to mDevice (type: camera_device_t) the value of the pointer to hw_device_t21:50
netchipi'm off to sleep21:55
MSameerwhat camera hal allocates is camera_device_t21:55
MSameergood night :)21:55
netchipit allocates hw_device_t, right?21:55
MSameerhal allocates camera_device_t21:55
MSameerand it gives it to us disguised as hw_device_t21:55
netchipthat was the part I didn't understand21:56
netchipgot it :)21:56
netchipanyways, gnight!21:56
MSameernight :)21:56
*** hexo has quit IRC22:24
*** hexo has joined #sailfishos-porters22:25
*** hexo has quit IRC22:27
*** hexo has joined #sailfishos-porters22:28
sledgessitu: ping23:24

Generated by 2.17.1 by Marius Gedminas - find it at!