Skip to Content
Computer Science & Perl Programming
book

Computer Science & Perl Programming

by Jon Orwant
November 2002
Intermediate to advanced
758 pages
19h 45m
English
O'Reilly Media, Inc.
Content preview from Computer Science & Perl Programming

Chapter 53. Controlling Modems

Bill Birthisel

Serial ports are one of the oldest black boxes in computing: data goes in, data comes out, and few people understand how, even though serial ports have been around much longer than PCs and haven’t changed much over the years. They’re still a very common way to connect computers to their peripherals, or even computers to one another. This article describes how to use the Win32::SerialPort module to talk to devices like modems from your Win32 Perl programs. (If you’re not using Windows, the Device::SerialPort module, also on CPAN, provides the same interface for Linux, AIX, Solaris, and other POSIX operating systems.)

Before communicating, serial ports have to agree about a few things. Sometimes the agreement is pre-arranged; for instance, operating systems typically know how to talk to many types of mice. But you probably have seen something like 9600,8N1 in a manual to describe a serial device configuration. Those are the serial characteristics: baud rate, data bits, parity, and stop bits.

Let’s look at what that 9600,8N1 means. At all times, a serial line either has a voltage difference across it (an “on” bit) or no voltage difference (an “off” bit). The 9600 defines the time between bits: 1/9,600 second. The 8 tells you how many bits there are per character. ASCII requires only seven bits, but most connections these days find a use for that eighth bit. An additional bit, the parity bit, is sometimes used as a simplistic checksum for the ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Advanced Perl Programming

Advanced Perl Programming

Sriram Srinivasan
Perl Hacks

Perl Hacks

Chromatic, Damian Conway, Curtis Ovid Poe, Curtis (Ovid) Poe
Perl One-Liners

Perl One-Liners

Peteris Krumins

Publisher Resources

ISBN: 9780596003104Errata Page