Search code examples
c#linuxmonogsmcomm

using GSMComm in Linux


I have developed a simple application (with VS2013) to send and received text messages via a GSM modem in C# using GSM Communication Library (GSMComm). Now, I want to use it on my “raspberry pi” with the help of mono. Everything is fine, but the big problem is, I have no idea what should I use instead of (in my case) COM3 to create a gsm connection (see the code below), as I know the name of my gsm-modem’s port in Linux is “ttyUSB0”.

GsmCommMain gsmPort = null;
…
gsmPort = new GsmCommMain(“COM3”, 9600 /*baudRate*/, 300 /*timeout*/);

Any idea?!


Solution

  • It appears the GSMPhone class is using a std SerialPort class, so:

    gsmPort = new GsmCommMain(“/dev/ttyUSB0”, 9600 /*baudRate*/, 300 /*timeout*/);
    

    Ref: https://github.com/welly87/GSMComm/blob/e49cd0d803afd9b3b53df178404981b12ab81f23/GSMCommunication/GsmCommunication/GsmPhone.cs#L154

    Ref: (old, but still valid reference) : http://www.mono-project.com/archived/howtosystemioports/

    1) Assuming you have gsm-utils installed (

    apt-get install gsm-utils

    2) Assuming you have the proper perms to access:

    sudo chmod 666 /dev/ttyUSB0

    3) Assuming you can connect to that dev via a serial program, something like:

    moserial, zterm, etc...

    4) Try using statserial to verify that dev device:

    statserial /dev/ttyUSB0