Changed Still Image Host class driver to auto-fill TransactionID element of sent...
[pub/USBasp.git] / Projects / AVRISP / Lib / V2Protocol.c
index 3a1b78e..3aa2d89 100644 (file)
@@ -308,6 +308,18 @@ static void V2Protocol_Command_ProgramMemory(uint8_t V2Command)
 \r
        Endpoint_Read_Stream_LE(&Write_Memory_Params, sizeof(Write_Memory_Params) - sizeof(Write_Memory_Params.ProgData));\r
        Write_Memory_Params.BytesToWrite = SwapEndian_16(Write_Memory_Params.BytesToWrite);\r
+       \r
+       if (Write_Memory_Params.BytesToWrite > sizeof(Write_Memory_Params.ProgData))\r
+       {\r
+               Endpoint_ClearOUT();\r
+               Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);\r
+\r
+               Endpoint_Write_Byte(V2Command);\r
+               Endpoint_Write_Byte(STATUS_CMD_FAILED);\r
+               Endpoint_ClearIN();\r
+               return;\r
+       }\r
+       \r
        Endpoint_Read_Stream_LE(&Write_Memory_Params.ProgData, Write_Memory_Params.BytesToWrite);\r
 \r
        Endpoint_ClearOUT();\r
@@ -407,7 +419,6 @@ static void V2Protocol_Command_ProgramMemory(uint8_t V2Command)
 \r
        Endpoint_Write_Byte(V2Command);\r
        Endpoint_Write_Byte(ProgrammingStatus);\r
-       \r
        Endpoint_ClearIN();\r
 }\r
 \r