5 Replies - 2566 Views - Last Post: 11 July 2014 - 12:59 AM Rate Topic: -----

#1 joelmpott  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 07-July 14

USB to text file program

Posted 07 July 2014 - 12:32 PM

Hello,

I am very new to C++, and have only done a few simple programs (programming is not my major, but I've been asked do this job on top of my other projects and want to do the best I can). I have been tasked to interface an old piece of equipment at our facility with a laptop in the same room. The laptop is to read the data input through USB and print to a text file. The equipment uses an RS485 serial output. Is this possible to do in C++? Can anyone point me to some helpful resources on getting the job done?

Thank you in advance,

Joel

Is This A Good Question/Topic? 0
  • +

Replies To: USB to text file program

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6246
  • View blog
  • Posts: 24,014
  • Joined: 23-August 08

Re: USB to text file program

Posted 07 July 2014 - 12:56 PM

Perhaps this tutorial on libusb might be helpful?
Was This Post Helpful? 0
  • +
  • -

#3 Salem_c  Icon User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 2142
  • View blog
  • Posts: 4,207
  • Joined: 30-May 10

Re: USB to text file program

Posted 07 July 2014 - 10:27 PM

Since RS485 and USB have different connectors, voltages, protocols etc, you'll first need a hardware dongle to convert between the two. Given the scope of the lab assignment, you should already have access to something like this.
https://www.google.c...o+usb+converter

A thorough read of the manual for your dongle is an essential step.

Any decent dongle will auto-install on windows and just provide you with a COMn port (n being some number >= 1). Prior to windows7, you could then just run hyperterminal to check out a serial line before writing any code at all.

Once you figured out the baud rate, start bit, stop bit and parity parameters of the serial line, writing code to do the same thing was pretty easy.
Was This Post Helpful? 1
  • +
  • -

#4 snoopy11  Icon User is online

  • Engineering ● Software
  • member icon

Reputation: 1456
  • View blog
  • Posts: 4,712
  • Joined: 20-March 10

Re: USB to text file program

Posted 08 July 2014 - 05:44 AM

After Salem_c's Great advice,

all you need is a device driver so this should do it

Driver

Snoopy.
Was This Post Helpful? 0
  • +
  • -

#5 joelmpott  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 07-July 14

Re: USB to text file program

Posted 08 July 2014 - 06:46 AM

Thank you all for the great suggestions, you have been very helpful. I will try them out ASAP.

Joel
Was This Post Helpful? 0
  • +
  • -

#6 horace  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 768
  • View blog
  • Posts: 3,832
  • Joined: 25-October 06

Re: USB to text file program

Posted 11 July 2014 - 12:59 AM

the FDTI USB/RS485 modules create a COM port
http://www.ftdichip....es/USBRS485.htm

Visual Studio C++, C#, VB, etc has a SerialPort component which you can use to communicate with the COM port
Alternativly you could use CodeBlocks with the gcc compiler - there are a number of serial port libraries on the web that can then be used to communicate with COM ports
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1