Hi,I am trying to develop an application using C to try and interface to the arduino board using the libusb library available from sourceforge.net.

My level of C is poor and am having some problems understanding how to use and understand some of the functions. Basically I have developed code on the arduino which samples weather conditions from sensors. The plan is to have a C program on the PC which runs every 10 mins and sends for example T for temperature and H when it wants a humidiity reading etc.. Anyway I have some of the C code written to send these characters and from using LED's on the arduino board, I can see that the arduino board successfully receives and responds with the relevant data. The problem I am having is in reading the data which the arduino responds with. Below is my code:

When I call the usb_bulk_write function it returns a 1 to say it was run successfully and the arduino seems to respond. I don't understand what I have to do to read data. Using the usb_bulk_read does not work for me. I can't fully grasp how it should be used. I also don't fully understand what is meant by endpoints?When the arduino board responds using the serial.write function, is this data automatically transmitted, or is it held in a buffer until another application requests it? I would be very grateful if anyone who has experience using libusb or who understands a little more about USB than me could point me in the right direction.I think I'm getting close to a solution but i have found it difficult to find help on the use of libusb.

Hi Phil,No there is no real reason for using libusb. When you say serial port are you referring to RS232 or USB?

If there are other methods which may be simpler to implement and there is no easy way to overcome the problem that I am having with libusb, then I would have no problem in changing as I'm not to knowlegable in this area.

Yes I am using an arduino duemilanova with an FDTI chip. Please if you have time explain to me a little regarding what drivers I need to use and what language etc. I am using windows xp.

I was reading the section about interfacing with software http://www.arduino.cc/playground/Main/InterfacingWithSoftware but I ended up with more questions after reading it. I am bit knew to this side of things.

I´d be very grateful if some one could just point me in the right direction. I am more than happy to begin studying something if I know it´s possible to use the method. It´s just that now with my limited knowledge I find it difficult to get stuck into a certain topic when I don´t understand the basics of it.

Thank you for the responses.Yes I have downloaded the drivers and installed them from the ftdi site. I can download and run programs on the board without problems.

Quote

If so, you are done - all the drivers are present and accounted for.

You make it sound easy! I'd be very grateful if someone could give me some advice on the next step from here using windows. In the meantime I am going to dig out some old serial port code I had and see what I can do.

Hi again kg4wsv,It seems it was as easy as you made it sound!!!!I had a look at my old code I used a few years ago while messing around with serials ports and after a few modifications it seems to be working. So thank you all very much for sending me in the right direction. I would still be here come next Chrristmas using the libusb approach!

Incidentally I am using C, originally I was using Dev-C++ but it doesn't support the conio.h librray so I reverted to TurboC (from my college days) and with it I can use the same functions.

Does anyone know if there is a more modern free compiler which would support the conio library?

Anyway, thank you all so much for your suggestions, I am so grateful really.

(EDIT: I'll post my code here once I finish modyfing it for anyone in the same boat as me)

the todbot code above should work in dev-c++ since it uses termios for the serial port. Once you open() the port, it's easy to read() and write(). If you want to use conio, google turned up a few results of people modifying dev-c++ to use it.

If you want to use the windows libraries, you could download visual c++ express (for free). But i have no idea which windows libraries manage serial port communication.

Hi againAs promised here is my code. I put it here in the hope that it may save someone from hours of googling and may send them in the right direction. The code is nothing special but hopefully it will help someone get started. Basically all it does is send a chaaracter, wait and read a response.