public int execWriteRequest(IPDU p, IresultSet rl)//not checked
        {
            Pdu p2;
            byte[] q;
            resultN cr;//, c2;
            int res, i;
            p2 = ExchangePdu((Pdu)p);
            //if (res != daveResOK) return res;
            //res=_daveSetupReceivedPDU(dc, &p2);
            //if(res!=daveResOK) return res;
            res = p2.testReadResultMulti();
            if (res != Connection.daveResOK) return res;
            if (rl != null)
            {
                //cr=(daveResult*)calloc(p2.param[1], sizeof(daveResult));
                int numResults = p2.Param[1];
                //rl->results=cr;
                //c2=cr;
                //q=p2.data;
                q = p2.Data.ToArray();
                i = 0;
                int countQ = 0;
                while (i < p2.Param[1])
                {
                    cr = new resultN();
                    /*		printf("result %d: %d  %d %d %d\n",i, *q,q[1],q[2],q[3]); */
                    cr.error = Connection.daveUnknownError;
                    if (q[countQ] == 0x0A)
                    {	/* 300 and 400 families */
                        cr.error = Connection.daveResItemNotAvailable;
                    }
                    else if (q[countQ] == 0x03)
                    {	/* 200 family */
                        cr.error = Connection.daveResItemNotAvailable;
                    }
                    else if (q[countQ] == 0x05)
                    {
                        cr.error = Connection.daveAddressOutOfRange;
                    }
                    else if (q[countQ] == 0xFF)
                    {
                        cr.error = Connection.daveResOK;
                    }
                    else if (q[countQ] == 0x07)
                    {
                        cr.error = Connection.daveWriteDataSizeMismatch;
                    }
                    /*		    printf("Error %d\n", c2->error); */
                    countQ++;
                    //c2++;
                    i++;
                    ((daveResultN)rl).allResults.Add(cr);
                }
            }
            return res;

        }
        /*public int execReadRequest(IPDU p, IresultSet rl)//!!!!!!!!!!!!!!!!!! for delete
        {
            return 0;
        }*/
        public int execReadRequest(IPDU p, IresultSet rl)
        {
            //int DECL2 daveExecReadRequest(daveConnection * dc, PDU *p, daveResultSet* rl){
            Pdu p2;
            byte[] q, qU;
            resultN cr;//, c2;
            int res, i, len, rlen;

            AnswLen = 0;	// 03/12/05
            //dc->resultPointer=NULL;
            //dc->_resultPointer=NULL;
            //res=_daveExchange(dc, p);
            p2 = ExchangePdu((Pdu)p);
            //if (res!=daveResOK) return res;
            //res=_daveSetupReceivedPDU(dc, &p2);
            //if (res!=daveResOK) return res;
            res = p2.testReadResultMulti();
            if (res != Connection.daveResOK) return res;
            i = 0;
            if (rl != null)
            {
                //cr=(daveResult*)calloc(p2.param[1], sizeof(daveResult));
                int numResults = p2.Param[1];
                //rl->results=cr;
                //c2=cr;
                q = p2.Data.ToArray();
                //qU = p2.UData.ToArray();
                int countQ = 0;

                rlen = p2.Data.Count;
                while (i < p2.Param[1])
                {
                    cr = new resultN();
                    /*	    printf("result %d: %d  %d %d %d\n",i, *q,q[1],q[2],q[3]); */
                    if ((q[countQ] == 255) && (rlen > 4))
                    {
                        len = q[countQ + 2] * 0x100 + q[countQ + 3];
                        if (q[countQ + 1] == 4)
                        {
                            len >>= 3;	/* len is in bits, adjust */
                        }
                        else if (q[countQ + 1] == 5)
                        {			/* Fehlenden Size-Type INTEGER ergдnzt */
                            len >>= 3;	/* len is in bits, adjust */
                        }
                        else if (q[countQ + 1] == 7)
                        {			/* Fehlenden Size-Type REAL ergдnzt */
                            /* len is already in bytes, ok */
                        }
                        else if (q[countQ + 1] == 9)
                        {
                            /* len is already in bytes, ok */
                        }
                        else if (q[countQ + 1] == 3)
                        {
                            /* len is in bits, but there is a byte per result bit, ok */
                        }
                        else
                        {
                            //if (daveDebug & daveDebugPDU)
                            //	LOG2("fixme: what to do with data type %d?\n",q[1]);
                        }
                    }
                    else
                    {
                        len = 0;
                    }
                    /*	    printf("Store result %d length:%d\n", i, len); */
                    //c2->length=len;
                    if (len > 0)
                    {
                        //c2.bytes=(uc*)malloc(len);
                        //memcpy(c2->bytes, q+4, len);
                        cr.bytes = new byte[len];
                        Array.Copy(q, countQ + 4, cr.bytes, 0, len);
                    }
                    cr.error = Connection.daveUnknownError;

                    if (q[countQ] == 0xFF)
                    {
                        cr.error = Connection.daveResOK;
                    }
                    else
                        cr.error = q[countQ];

                    /*	    printf("Error %d\n", c2->error); */
                    //q+=len+4;
                    countQ += len + 4;
                    rlen -= len;
                    if ((len % 2) == 1)
                    {
                        countQ++;
                        rlen--;
                    }
                    //c2++;
                    ((daveResultN)rl).allResults.Add(cr);
                    i++;
                }
            }
            return res;

        }