![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Expert Programmer
|
I am working as a summer intern at a large company. My responsibilities involve writing scripts to accomplish various tasks.
I was recently asked if I would write a script to interface with an external device. All I know so far is that the device records temperatures and connects to a computer via a serial port. I have never attempted this sort of thing before, and I was hoping someone more experienced could point me in the right direction. I currently have no idea how get a reference to a computer's ports or read data from them. Is there a standard way to connect to/read from a computer's ports? Or does each device have its own API, and if so, how would I find this information as it pertains to a particular device? In addition, is it likely that I will be restricted to coding in C++, or will I be able to use a higher-level language such as Python? Thanks in advance for your replies. |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Heaven knows why we always mention this, but you need to specify your platform and OS. I guess if people ever designed one of those effers they might know why we're so silly.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Programmer
|
You can use a High Level Language like python. BUT YOU MAY NEED TO CREATE A DRVIVER. I once made a QB program compatable with a bar code scanner. I made a driver using C++ that would read it's serial port input it and enter it just like a keyboard does. But python is not good for devices. Use some c++ to asign it a COM PORT 1 or 2 then use QB to read input from it.
__________________
Get programming and game creation tutorials and discuss apon you peers at http://s14.invisionfree.com/tsoft We also accept custom software requests and new mods will be needed soon |
|
|
|
|
|
#4 |
|
Expert Programmer
|
I'm using Windows XP. That's all I know at the moment; I'll post again when I have more details about the project.
|
|
|
|
|
|
#5 |
|
Programmer
|
Well with XP you are probably using an X86 architecture
__________________
Get programming and game creation tutorials and discuss apon you peers at http://s14.invisionfree.com/tsoft We also accept custom software requests and new mods will be needed soon |
|
|
|
|
|
#6 |
|
Professional Programmer
Join Date: May 2006
Location: Maryland, USA
Posts: 306
Rep Power: 3
![]() |
PySerial
|
|
|
|
|
|
#7 |
|
Expert Programmer
|
I'm interested in how you would go about connecting to and reading from/to a serial port without using other people's wrapper classes (although that is probably what I'll end up using). How do the people who write the wrapper classes (such as PySerial and USPP) get access to the serial ports?
|
|
|
|
|
|
#8 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Quote:
PySerial just takes all the above approaches and stuffs them into one cross-platform library. |
|
|
|
|
|
|
#9 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
With XP you have to get out of fully-protected mode and get at the hardware, or use someone else's code (driver or wrapper or whatever) that does. It gets in the way when you decide to get down and dirty, but it keeps lebenty-zillion users from wiping out their system every time they turn around. If you want to get directly at it, yourself, you have to go that way, and you'll have to study serial devices, how you know when they're ready to transmit or receive, how to set up the bit rates and formats, all that hooey. It's interesting and fun the first several times you do it (if you aren't blowing a delivery date), but it probably isn't what your bosses want. They could be tasking you with it, just to see how you handle it, but they probably want a job done.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#10 |
|
Expert Programmer
|
Thanks for all the replies. It sounds like I'll be going with PySerial or a similar library.
I suppose the real question is, how do I determine how to interpret the data that is read from the port? I assume most devices don't come with a manual detailing how to interpret the bits it sends to the computer. Does the way data is sent depend on the port, or the device sending it to the port? Is there usually a reference for this sort of thing? |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Data logging problem from the serial port | jerryleo | Perl | 0 | Jan 10th, 2006 8:47 AM |
| Help in QBASIC (I think it's similar to VB) | phoenix987 | Visual Basic | 3 | May 9th, 2005 1:33 PM |
| Help with a QBASIC program | phoenix987 | Other Programming Languages | 4 | May 5th, 2005 1:27 PM |
| Script to output HDD data to serial port | Europa2010AD | C | 2 | Apr 6th, 2005 2:37 PM |
| Printer Port Programming | shadowhunter | C++ | 3 | Feb 28th, 2005 5:16 AM |