예제 #1
0
        FTDIBoxRequest(FTDIBoxRequestAddress address, IEnumerable <byte> data, IRequest deviceRequest, DeviceOperationScope scope)
        {
            _deviceRequest = deviceRequest;
            Address        = address;
            _scope         = scope;

            switch (Address)
            {
            case FTDIBoxRequestAddress.HS_SET_LOW_SPEED_MODE:
                Serialized    = new byte[] { 0, 16 };
                _responseInfo = new ResponseInfo(ResponseReadMode.CONSTRAINED_BY_ANSWER, 2, new byte[] { 0, 16 });
                break;

            case FTDIBoxRequestAddress.LS_SET_HIGH_SPEED_MODE:
                Serialized    = new byte[] { 92, 12 };
                _responseInfo = new ResponseInfo(ResponseReadMode.CONSTRAINED_BY_ANSWER, 2, new byte[] { 92, 12 });
                break;

            case FTDIBoxRequestAddress.HS_ACTIVATE_CHANNEL4:
                Serialized    = new byte[] { 0, 20 };
                _responseInfo = new ResponseInfo(ResponseReadMode.CONSTRAINED_BY_ANSWER, 2, new byte[] { 0, 20 });
                break;

            case FTDIBoxRequestAddress.LS_ACTIVATE_CHANNEL4:
                Serialized    = new byte[] { 92, 10 };
                _responseInfo = new ResponseInfo(ResponseReadMode.CONSTRAINED_BY_ANSWER, 2, new byte[] { 92, 10 });
                break;

            case FTDIBoxRequestAddress.HS_GET_FLASH_LENGTH:
                Serialized    = new byte[] { 9, 128, 170, 206, 0, 0, 0, 0, 0, 2 };
                _responseInfo = new ResponseInfo(ResponseReadMode.CONSTRAINED_BY_ANSWER, 6, null);
                break;

            case FTDIBoxRequestAddress.HS_READ_ALL_FLASH:
                Timeout       = RequestTimeout.INFINITY;
                Serialized    = new byte[] { 9, 128, 170, 206, 0, 0, 0, 0, 0, 3 };
                _responseInfo = new ResponseInfo(ResponseReadMode.TILL_TIMEOUT, ResponseLength.UNKNOWN, null);
                break;

            case FTDIBoxRequestAddress.LS_DEVICE_REQUEST:
                Serialized = new Enumerable <byte>()
                {
                    0xFF, 0x00,
                    data.Count().ToUInt16().SerializeAsNumber(false),
                    data
                };
                _responseInfo = new ResponseInfo(ResponseReadMode.READ_BY_TARGET, ResponseLength.UNKNOWN, null);
                break;

            default:
                throw new NotSupportedException();
            }
        }
예제 #2
0
 internal static FTDIBoxRequest CreateCommandRequest(FTDIBoxRequestAddress address, DeviceOperationScope scope)
 {
     return(new FTDIBoxRequest(address, null, null, scope));
 }