Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Serial Communications w/ PoSH

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 07-19-2007   #1 (permalink)
robsmith
Guest


 

Serial Communications w/ PoSH

Hello,

I am trying to write and read frm a serial port with Powershell.

I found Jeff Snover's post on the Powershell MSDN blog, but Powershell
craches whenever I add anything to the DataReceived event.

If anyone has any samples of how to open a COM Port, write a few CRLF and
read the result, I would appreciate it!.

Thanks,

Bob

My System SpecsSystem Spec
Old 07-20-2007   #2 (permalink)
/\/\o\/\/ [MVP]
Guest


 

RE: Serial Communications w/ PoSH

async eventsupport is not yet supported natively , you can only "wait" for
the event

you can use Oisins excelent event library for this

http://www.codeplex.com/PSEventing

Greetings /\/\o\/\/
http://thePowerShellGuy.com

"robsmith" wrote:

> Hello,
>
> I am trying to write and read frm a serial port with Powershell.
>
> I found Jeff Snover's post on the Powershell MSDN blog, but Powershell
> craches whenever I add anything to the DataReceived event.
>
> If anyone has any samples of how to open a COM Port, write a few CRLF and
> read the result, I would appreciate it!.
>
> Thanks,
>
> Bob

My System SpecsSystem Spec
Old 07-20-2007   #3 (permalink)
robsmith
Guest


 

RE: Serial Communications w/ PoSH

Mow,

Thanks for the reply. I tried it and can receive events, but I am having
difficulty looking at the actual data returned. Args.Data does not appear to
exist ...

Any help would be appreciated.

Thanks,

Bob

PS C:\PoSHeventing> get-eventbinding port

VariableName EventName TypeName
Listening
------------ --------- --------
---------
port DataReceived SerialPort
True


PS C:\PoSHeventing> $events
PS C:\PoSHeventing> $event

Occurred Source Name
Args
-------- ------ ----
----
7/20/2007 8:24:13 AM System.Management.Automati... DataReceived
System.IO.Ports.SerialData...
7/20/2007 8:24:13 AM System.Management.Automati... DataReceived
System.IO.Ports.SerialData...
7/20/2007 8:24:13 AM System.Management.Automati... DataReceived
System.IO.Ports.SerialData...
7/20/2007 8:24:13 AM System.Management.Automati... DataReceived
System.IO.Ports.SerialData...
7/20/2007 8:24:13 AM System.Management.Automati... DataReceived
System.IO.Ports.SerialData...
7/20/2007 8:24:13 AM System.Management.Automati... DataReceived
System.IO.Ports.SerialData...






"/\/\o\/\/ [MVP]" wrote:

> async eventsupport is not yet supported natively , you can only "wait" for
> the event
>
> you can use Oisins excelent event library for this
>
> http://www.codeplex.com/PSEventing
>
> Greetings /\/\o\/\/
> http://thePowerShellGuy.com
>
> "robsmith" wrote:
>
> > Hello,
> >
> > I am trying to write and read frm a serial port with Powershell.
> >
> > I found Jeff Snover's post on the Powershell MSDN blog, but Powershell
> > craches whenever I add anything to the DataReceived event.
> >
> > If anyone has any samples of how to open a COM Port, write a few CRLF and
> > read the result, I would appreciate it!.
> >
> > Thanks,
> >
> > Bob

My System SpecsSystem Spec
Old 07-21-2007   #4 (permalink)
/\/\o\/\/ [MVP]
Guest


 

RE: Serial Communications w/ PoSH

hio Rob sorry I can't test

what is the output of
$a = $events[0].args
$a
$a.psbase

greetings /\/\o\/\/

"robsmith" wrote:

> Mow,
>
> Thanks for the reply. I tried it and can receive events, but I am having
> difficulty looking at the actual data returned. Args.Data does not appear to
> exist ...
>
> Any help would be appreciated.
>
> Thanks,
>
> Bob
>
> PS C:\PoSHeventing> get-eventbinding port
>
> VariableName EventName TypeName
> Listening
> ------------ --------- --------
> ---------
> port DataReceived SerialPort
> True
>
>
> PS C:\PoSHeventing> $events
> PS C:\PoSHeventing> $event
>
> Occurred Source Name
> Args
> -------- ------ ----
> ----
> 7/20/2007 8:24:13 AM System.Management.Automati... DataReceived
> System.IO.Ports.SerialData...
> 7/20/2007 8:24:13 AM System.Management.Automati... DataReceived
> System.IO.Ports.SerialData...
> 7/20/2007 8:24:13 AM System.Management.Automati... DataReceived
> System.IO.Ports.SerialData...
> 7/20/2007 8:24:13 AM System.Management.Automati... DataReceived
> System.IO.Ports.SerialData...
> 7/20/2007 8:24:13 AM System.Management.Automati... DataReceived
> System.IO.Ports.SerialData...
> 7/20/2007 8:24:13 AM System.Management.Automati... DataReceived
> System.IO.Ports.SerialData...
>
>
>
>
>
>
> "/\/\o\/\/ [MVP]" wrote:
>
> > async eventsupport is not yet supported natively , you can only "wait" for
> > the event
> >
> > you can use Oisins excelent event library for this
> >
> > http://www.codeplex.com/PSEventing
> >
> > Greetings /\/\o\/\/
> > http://thePowerShellGuy.com
> >
> > "robsmith" wrote:
> >
> > > Hello,
> > >
> > > I am trying to write and read frm a serial port with Powershell.
> > >
> > > I found Jeff Snover's post on the Powershell MSDN blog, but Powershell
> > > craches whenever I add anything to the DataReceived event.
> > >
> > > If anyone has any samples of how to open a COM Port, write a few CRLF and
> > > read the result, I would appreciate it!.
> > >
> > > Thanks,
> > >
> > > Bob

My System SpecsSystem Spec
Old 07-23-2007   #5 (permalink)
robsmith
Guest


 

RE: Serial Communications w/ PoSH

Mow,

Here's the output you requested ...

PS C:\Documents and Settings\robsmith> $port


BaseStream : System.IO.Ports.SerialStream
BaudRate : 1200
BreakState : False
BytesToWrite : 0
BytesToRead : 23
CDHolding : False
CtsHolding : False
DataBits : 8
DiscardNull : False
DsrHolding : False
DtrEnable : False
Encoding : System.Text.ASCIIEncoding
Handshake : None
IsOpen : True
NewLine :

Parity : None
ParityReplace : 63
PortName : COM1
ReadBufferSize : 4096
ReadTimeout : -1
ReceivedBytesThreshold : 1
RtsEnable : False
StopBits : One
WriteBufferSize : 2048
WriteTimeout : -1
Site :
Container :



PS C:\Documents and Settings\robsmith> $e

Occurred Source Name
Args
-------- ------ ----
----
7/23/2007 9:45:11 AM System.Management.Automati... DataReceived
System.IO.Ports.SerialData...
7/23/2007 9:45:11 AM System.Management.Automati... DataReceived
System.IO.Ports.SerialData...
7/23/2007 9:45:11 AM System.Management.Automati... DataReceived
System.IO.Ports.SerialData...
7/23/2007 9:45:11 AM System.Management.Automati... DataReceived
System.IO.Ports.SerialData...
7/23/2007 9:45:11 AM System.Management.Automati... DataReceived
System.IO.Ports.SerialData...
7/23/2007 9:45:11 AM System.Management.Automati... DataReceived
System.IO.Ports.SerialData...
7/23/2007 9:45:24 AM System.Management.Automati... DataReceived
System.IO.Ports.SerialData...


PS C:\Documents and Settings\robsmith> get-eventbinding

VariableName EventName TypeName
Listening
------------ --------- --------
---------
port DataReceived SerialPort
True


PS C:\Documents and Settings\robsmith> $e[0].Args


EventType

---------

Chars
PS C:\Documents and Settings\robsmith> $a


EventType

---------

Chars


PS C:\Documents and Settings\robsmith> $a.psbase


EventType

---------

Chars


I also posted to a discussion on Oisin's site, haven't heard back yet.

Thanks for the help,

Bob


"/\/\o\/\/ [MVP]" wrote:

> hio Rob sorry I can't test
>
> what is the output of
> $a = $events[0].args
> $a
> $a.psbase
>
> greetings /\/\o\/\/
>
> "robsmith" wrote:
>
> > Mow,
> >
> > Thanks for the reply. I tried it and can receive events, but I am having
> > difficulty looking at the actual data returned. Args.Data does not appear to
> > exist ...
> >
> > Any help would be appreciated.
> >
> > Thanks,
> >
> > Bob
> >
> > PS C:\PoSHeventing> get-eventbinding port
> >
> > VariableName EventName TypeName
> > Listening
> > ------------ --------- --------
> > ---------
> > port DataReceived SerialPort
> > True
> >
> >
> > PS C:\PoSHeventing> $events
> > PS C:\PoSHeventing> $event
> >
> > Occurred Source Name
> > Args
> > -------- ------ ----
> > ----
> > 7/20/2007 8:24:13 AM System.Management.Automati... DataReceived
> > System.IO.Ports.SerialData...
> > 7/20/2007 8:24:13 AM System.Management.Automati... DataReceived
> > System.IO.Ports.SerialData...
> > 7/20/2007 8:24:13 AM System.Management.Automati... DataReceived
> > System.IO.Ports.SerialData...
> > 7/20/2007 8:24:13 AM System.Management.Automati... DataReceived
> > System.IO.Ports.SerialData...
> > 7/20/2007 8:24:13 AM System.Management.Automati... DataReceived
> > System.IO.Ports.SerialData...
> > 7/20/2007 8:24:13 AM System.Management.Automati... DataReceived
> > System.IO.Ports.SerialData...
> >
> >
> >
> >
> >
> >
> > "/\/\o\/\/ [MVP]" wrote:
> >
> > > async eventsupport is not yet supported natively , you can only "wait" for
> > > the event
> > >
> > > you can use Oisins excelent event library for this
> > >
> > > http://www.codeplex.com/PSEventing
> > >
> > > Greetings /\/\o\/\/
> > > http://thePowerShellGuy.com
> > >
> > > "robsmith" wrote:
> > >
> > > > Hello,
> > > >
> > > > I am trying to write and read frm a serial port with Powershell.
> > > >
> > > > I found Jeff Snover's post on the Powershell MSDN blog, but Powershell
> > > > craches whenever I add anything to the DataReceived event.
> > > >
> > > > If anyone has any samples of how to open a COM Port, write a few CRLF and
> > > > read the result, I would appreciate it!.
> > > >
> > > > Thanks,
> > > >
> > > > Bob

My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
NewLine in PoSh greatbarrier86 PowerShell 10 07-07-2008 02:43 PM
Re: Serial Plonkers v. Serial Killers kurttrail Vista General 0 04-16-2008 10:20 AM
PoSh: Quine dreeschkind PowerShell 12 05-30-2007 01:24 PM
PoSH Vista !! /\\/\\o\\/\\/ [MVP] PowerShell 4 01-30-2007 03:27 PM
PoSh quiz dreeschkind PowerShell 7 01-30-2007 10:54 AM


Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51