About
Community
Bad Ideas
Drugs
Ego
Erotica
Fringe
Society
Technology
register | bbs | search | rss | faq | about
meet up | add to del.icio.us | digg it
Go Back   Community > Technology > Everything *NIX
Register FAQ Members List Calendar Today's Posts

Everything *NIX This is a general forum about all forms of *nix. Post your ideas and thoughts on this wonderful OS family. Talk about your personal favorite flavor of *nix and why you think it's so much better than the others. Anything pertaining to *nix and *nix administration should be posted here.

Reply
 
Thread Tools Display Modes
  #1   Add hoaxe to your ignore list  
Old 2008-07-25, 01:06
hoaxe hoaxe is offline
Regular
 
Arrow i am in way over my head - blueZ libs in c++ - i am dying here

i need some help,

a pointer in the right direction. a manual online or some serious documentation. i must be blind or stupid because there is something i am not seeing? or what? fuck i don't know

ok so here's my problem.
i am using open frameworks, it's a c++ library, let's me do all the artsy stuff i love and it's really easy and i love using it.
but
but
but
recently, i've been experimenting with bluetooth devices and i want to push that in with open frameworks.

usually, i connect to my device through the terminal by typing "hidd --search" from there, if i type "hcidump" i get to see all the hex data data is being sent to my computer from the device.

i want the hci dump in my open frameworks application and i have no fucking clue how to make it appear. i keep getting errors left and right.

i went here: http://www.bluez.org but they have no documentation on their site.
even with the hcidump header file, which i downloaded from the bluez.org site, the parser.h header that contains the function i probably want: "void hex_dump(int level, struct frame *frm, int num);" i still can't quite get there.

i can't even compile the thing, it keeps giving me an error:
/usr/include/hcidump/parser/parser.h|162|error: invalid conversion from ‘void*’ to ‘uint8_t*’|

what the hell does that mean?

what ever uint8, uint16 and uint32 etc, what ever they are, they are extremely problematic!!!

anyone with a tip to get hcidump through a c++ app, i would be thankful to.
Reply With Quote
  #2   Add pty to your ignore list  
Old 2008-07-25, 07:28
pty pty is offline
Regular
 
Default Re: i am in way over my head - blueZ libs in c++ - i am dying here

I don't know much about bluetooth, but I think I can help with your C problems.

the data types uint8, uint16 and uint32 are unsigned integers, the numbers are the amount of bits in that type.

uint8_t --> byte [unsigned char]
uint16_t --> word [unsigned short]
uint32_t --> long [unsigned long]

these types are defined in <stdint.h>

the error you are getting is because you cannot do an implicit conversion from a void pointer to any other pointer type in C++ without a cast, take for example:

note: malloc is a void*

Code:
#include <stdio.h>
#include <stdint.h>
#include <malloc.h>

int main(void)
  {
  uint8_t *a;
  a=malloc(5);
  return 0;
  }
it will compile just fine under gcc, but with g++ you will receive an error:

Code:
test.c: In function 'int main()':
test.c:9: error: invalid conversion from 'void*' to 'uint8_t*'
you need a cast in c++, so just place '(uint8_t *)' in front of malloc and everything will work. it may be harder to fix in someone elses code though.

if you keep having problems, to get the output of hcidump in your C++ program you can read the input from the command with popen:

http://www.gnu.org/software/libc/man...ubprocess.html

the hcidump man page also says:

Quote:
-w <file>, --save-dump=<file>
Parse output is not printed to screen, instead data read from device is saved in file file. The saved dump
file can be subsequently parsed with option -r.
so you could try to execute hcidump with argument '-w /tmp/hcidump', then read from the temp file.

Last edited by pty; 2008-07-25 at 07:39.
Reply With Quote
  #3   Add hoaxe to your ignore list  
Old 2008-07-25, 12:25
hoaxe hoaxe is offline
Regular
 
Talking Re: i am in way over my head - blueZ libs in c++ - i am dying here

thanks a lot pty, good stuff, good tips. i will read over this again when i work on it tonight. totse never fails!
Reply With Quote
  #4   Add hoaxe to your ignore list  
Old 2008-07-25, 18:56
hoaxe hoaxe is offline
Regular
 
Default Re: i am in way over my head - blueZ libs in c++ - i am dying here

i've been playing wit it a bit. there is something else i don't understand.

this is right after the includes
Code:
struct frame {
	void		*data;
	uint32_t	data_len;
	void		*ptr;
	uint32_t	len;
	uint16_t	dev_id;
	uint8_t		in;
	uint8_t		master;
	uint16_t	handle;
	uint16_t	cid;
	uint16_t	num;
	uint8_t		dlci;
	uint8_t		channel;
	unsigned long	flags;
	struct timeval	ts;
	int		pppdump_fd;
	int		audio_fd;
};
notice *ptr

and this is the problematic code block
Code:
static inline uint8_t get_u8(struct frame *frm)
{
	uint8_t *u8_ptr = frm->ptr;
	frm->ptr += 1;
	frm->len -= 1;
	return *u8_ptr;
}
i'd like to know what does this do:
Code:
frm->ptr
that little "->" i really don't understand it.
Reply With Quote
  #5   Add pty to your ignore list  
Old 2008-07-25, 19:17
pty pty is offline
Regular
 
Default Re: i am in way over my head - blueZ libs in c++ - i am dying here

Quote:
Originally Posted by hoaxe View Post
i'd like to know what does this do:

Code:
frm->ptr
that little "->" i really don't understand it.
http://www.space.unibe.ch/comp_doc/c....html#pointers
Reply With Quote
  #6   Add hoaxe to your ignore list  
Old 2008-07-26, 02:43
hoaxe hoaxe is offline
Regular
 
Default Re: i am in way over my head - blueZ libs in c++ - i am dying here

arrghh

fuck it. i spent like half my day on it

it's trying to do arithmetic with void types. wtf! i don't know enough c++ to deal with that kind of compile error
and even if i do get it to compile, i will have to figure out how to get the dump going.

no, too much. i'm either too inexperienced or this is something no one has done because i can't find anything about someone using hcidump inside their own program.

moving to solution number 2, the -w option to write the data to a file.
that should be easier to manage. it looks more like what i use to do with processing.org


why the fuck did i type this? it's like i hijacked my own thread and made it my project blog...

oh well
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

 
To the best of our knowledge, the text on this page may be freely reproduced and distributed.
 

totse.com certificate signatures
 
 
About | Community | Bad Ideas | Drugs | Ego | Erotica | Fringe | Society | Technology
Hot Topics