beautypg.com

ClearOne Writing StreamNet User Manual

Page 55

background image

Audio Driver Example

D-3

All specifications subject to change without notification. All rights reserved. Copyright © 2007 NetStreams

Main +1 512.977-9393 / fax +1 512.977.9398 / Toll Free Technical Support +1 866-353-3496

3600 W. Parmer Lane, Suite 100; Austin, TX 78727 /

www.netstreams.com.

-- function OnAsyncInput(stream, message)

-- Diego Alfarache

-- 09-20-2006

-- Get Input from Serial Port

function OnAsyncInput(stream, message)

debug("verbose", message)

local start = 0

if( message == nil ) then

return

end

if( message:find("[*]")) then

bIsV2 = true

local Power = message:match("PW(.)")

local Band = message:match("BD(.)")

local Frequency = message:match("FR(......)")

local Preset = message:match("PR(..)")

if( Power ) then

debug("verbose", "Power = "..Power)

if( Power == "0" ) then

-- power is off

bPwrOn = "0"

SendPower( true )

else

bPwrOn = "1"

end

end

if( Band ) then

debug("verbose", "Band = "..Band)

if( Band == "1" ) then

nBand = FM

elseif( Band == "2" ) then

nBand = AM

end

end

if( Frequency ) then

-- skip past any leading zeros

local start = Frequency:find("[123456789]")

Frequency = Frequency:sub(start,-1)

if( nBand == AM ) then

szFreq = "AM "..Frequency