# VB.net or C# samples for using AirLink Raven XT

**URL:** <https://forum.sierrawireless.com/t/vb-net-or-c-samples-for-using-airlink-raven-xt/5420>\
**Category:** AirLink routers\
**Created:** [January 25, 2012, 3:48pm UTC](https://forum.sierrawireless.com/t/vb-net-or-c-samples-for-using-airlink-raven-xt/5420 "2012-01-25T15:48:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Debaser](https://avatars.discourse-cdn.com/v4/letter/d/3da27b/32.png) [@Debaser](https://forum.sierrawireless.com/u/Debaser)\
**Post date:** [January 25, 2012, 3:48pm UTC](https://forum.sierrawireless.com/t/vb-net-or-c-samples-for-using-airlink-raven-xt/5420/1 "2012-01-25T15:48:30Z")

</div>

Hello all. We are building a stream gauge that will use a AirLink Raven XT for communication. I assume that the gauge hardware will be connected to the Raven via USB or Serial port. The current plan is to have an .asp page (or possibly a [vb.net](http://vb.net) exe) connect to the Raven, get a reading from the stream gauge, then store the data in a database on a hosted web server and then provide the stream flow via HTML or web services. This will be non-profit service for the kayaking community.

I have a good degree of database and [vb.net](http://vb.net) programming skills, but I’ve never used wireless devices, serial ports or USB ports. I hoping to find some very simple [vb.net](http://vb.net) (ideal) or C# code for connecting to the Raven, then connect to the stream gauge (assumed via serial or USB) to retrieve the reading, then have the reading passed back as a variable. I’d also like code for recording errors in the process.

Like I said, I’m new to a lot of this would appreciate responses with very basic info and very easy to use code samples.

Thanks!

---

<div class="post-metadata">

**Author:** ![lotam](https://avatars.discourse-cdn.com/v4/letter/l/958977/32.png) [@lotam](https://forum.sierrawireless.com/u/lotam)\
**Post date:** [January 26, 2012, 3:37am UTC](https://forum.sierrawireless.com/t/vb-net-or-c-samples-for-using-airlink-raven-xt/5420/2 "2012-01-26T03:37:40Z")

</div>

First, welcome.

May I ask what’s the options of interface and output of your stream gauge?  
How to get the data from it?

As you are using Airlink, you may check below for overview of ALEOS and what is offered, the management service included may help:  
[sierrawireless.com/productsa … tware.aspx](http://www.sierrawireless.com/productsandservices/AirLink/AirLinkSoftware.aspx)

---

<div class="post-metadata">

**Author:** ![zafer](https://avatars.discourse-cdn.com/v4/letter/z/439d5e/32.png) [@zafer](https://forum.sierrawireless.com/u/zafer)\
**Post date:** [January 26, 2012, 6:47am UTC](https://forum.sierrawireless.com/t/vb-net-or-c-samples-for-using-airlink-raven-xt/5420/3 "2012-01-26T06:47:32Z")

</div>

do you need a sample code in c# or vb which communicates with modem over serialport?  
if so, i can share a simple c# sample which demonstrates how to communicate over serialport.

```auto
// add this in using list
using System.IO.Ports;

// define needed variables
SerialPort m_serialport = null;
string m_incomingBuffer = "";

private void InitSerialPort()
{
       m_seriPort = new SerialPort();
       m_seriPort.PortName = "COM1";
       m_seriPort.BaudRate = 115200;
       m_seriPort.Parity = Parity.None;
       m_seriPort.DataBits = 8;
       m_seriPort.StopBits = StopBits.One;
       m_seriPort.Handshake = Handshake.None;
       m_seriPort.DtrEnable = true;
       m_seriPort.RtsEnable = true;
       m_seriPort.DataReceived += new SerialDataReceivedEventHandler(m_seriPort_DataReceived);
}
private void OpenSerialPort()
{
        // you must do error handling here
       m_seriPort.Open();
}
private void CloseSerialPort()
{
      // you must do error handling here
      m_seriPort.Close();
}
private void SendData(string data)
{
      // you must do error handling here
      m_seriPort.Write(data);
}

// this callback function will be triggered when there is some data on serialport
void m_seriPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
       m_incomingBuffer += m_seriPort.ReadExisting();
 }
```

And you can communicate with modem by the following routine. Of course you need error checking again.

```auto
// create serial port object and set its variables
InitSerialPort();
// open serial port object
OpenSerialPort();
// send AT command to modem
SendData("AT\r");
// you will then get "OK\r\n" response in "m_seriPort_DataReceived" function. And then you can send any other command or just close the port.
```
