Arduino DUE not work with SoftwareSerial.h

Hi, I’m trying to compile this code on arduino DUE (IDE 1.5.4) :

#include <SoftwareSerial.h>

const int pinRx = 7;
const int pinTx = 8;

SoftwareSerial sensor(pinTx,pinRx);

unsigned char flg_get = 0; // if get sensor data

const unsigned char cmd_get_sensor = {
0xff, 0x01, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00, 0x79};

bool sendCmdGetDta(int gas_strength, int temperature)
{
for(int i=0; i<sizeof(cmd_get_sensor); i++)
{
sensor.write(cmd_get_sensor
);

  • }*

  • long cnt_timeout = 0;*

  • while(!sensor.available()) // wait for data*

  • {*

  • delay(1);*

  • cnt_timeout++;*

  • if(cnt_timeout>1000)return 0; // time out*

  • }*

  • int len = 0;*

  • unsigned char dta[20];*

  • while(sensor.available())*

  • {*

  • dta[len++] = sensor.read();*

  • }*

  • if((9 == len) && (0xff == dta[0]) && (0x86 == dta[1])) // data ok*

  • {*
    gas_strength = 256dta[2]+dta[3];
    _ *temperature = dta[4] - 40;_

  • return 1;*

  • }*

  • return 0;*

}
void setup()
{

  • Serial.begin(115200);*

  • sensor.begin(9600);*
    }
    void loop()
    {
    // Serial.println(“get a ‘g’, begin to read from sensor!”);
    _ Serial.println("********************************************************");_

  • Serial.println();*

  • flg_get = 0;*

  • int gas, temp;*

  • if(sendCmdGetDta(&gas, &temp)) // get data ok*

  • {*
    // Serial.println("get data ok: ");

  • Serial.print("gas_strength = ");*

  • Serial.println(gas);*

  • // Serial.print("\ttemperature = ");*

  • // Serial.println(temp); *

  • }*

  • else*

  • {*

  • Serial.println(“get data error”);*

  • }*

  • delay(1000);*
    }
    void serialEvent()
    {

  • while (Serial.available())*

  • {*

  • char c = Serial.read();*

  • if(c == ‘g’)flg_get = 1;*

  • }*
    }
    But something going wrong, this is the error :
    CO2Sensor.ino:1:28: fatal error: SoftwareSerial.h: No such file or directory
    compilation terminated.
    If I change motherboard and compile the same code (Arduino UNO motherboard for example) everything is OK and the code running very well.
    I tried to use NewSoftwareSerial, AtSoftserial but nothing to do.
    Any suggest ?
    Thanks

Any suggest ?

Don't use SoftwareSerial with the Due.

Do use code tags when posting code.

Firstly don’t use 1.5.4, use 1.5.7, this is a Beta branch and it generally doesn’t help
to use older versions (which have more bugs).

Secondly the SoftwareSerial library uses AVR assembler and is not Due
compatible at all. Its not even in the Beta tree AFAICT.

The Due has 4 hardware serial channels IIRC.

Alternatively take on the task of porting the library to the Due and help others if
that’s your area of expertese.