private int BuildAndSendPDU(Pdu p2, byte[] pa, byte[] ud, byte[] ud2)
        {
            //int res;
            Pdu p = new Pdu(7);
            byte[] dn;
            //p.header=dc->msgOut+dc->PDUstartO;
            //_daveInitPDUheader(&p, 7);
            //_daveAddParam(&p, pa, psize);
            p.Param.AddRange(pa);

            //_daveAddUserData(&p, ud, usize);
            p.UData.AddRange(ud);
            //    LOG2("*** here we are: %d\n",p.dlen);
            //p3=&p;
            //dn= p3->data+p3->dlen;
            //p3->dlen+=usize2;
            //memcpy(dn, ud2, usize2);
            p.UData.AddRange(ud2);

            //((PDUHeader*)p3->header)->dlen=daveSwapIed_16(p3->dlen);

            Pdu rez = ExchangePdu(p);
            if (rez != null)
            {
                p2.Data = rez.Data;
                p2.Param = rez.Param;
                p2.initUData();

                return p2.testPGReadResult();
            }
            return -1;
        }
        public int _daveBuildAndSendPDU(Pdu myPDU, byte[] para, byte[] data, bool nullD)
        {
            //int res;
            Pdu p = new Pdu(7);
            byte[] nullData = { 0x0a, 0, 0, 0 };
            //p.header=dc->msgOut+dc->PDUstartO;
            //_daveInitPDUheader(&p, 7);

            //_daveAddParam(&p, pa, psize);

            p.Param.AddRange(para);

            if (data != null) p.UData.AddRange(data);
            else
                if (nullD) p.Data.AddRange(nullData);//_daveAddData(&p, nullData, 4);

            Pdu rez = ExchangePdu(p);
            if (rez != null)
            {
                myPDU.Data = rez.Data;
                myPDU.Param = rez.Param;
                myPDU.initUData();

                return myPDU.testPGReadResult();
            }
            return -1;
        }