File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -175,6 +175,33 @@ func rxHandler(b []byte) {
175175 }
176176}
177177
178+ /*
179+ Connection Happy Path Overview:
180+
181+ 0. MSC starts out in mscStateCmd status.
182+
183+ 1. Host sends CBW (Command Block Wrapper) packet to MSC.
184+ - CBW contains the SCSI command to be executed, the length of the data to be transferred, etc.
185+
186+ 2. MSC receives CBW.
187+ - CBW is validated and saved.
188+ - State is changed to mscStateData.
189+ - MSC routes the command to the appropriate SCSI command handler.
190+
191+ 3. The MSC SCSI command handler responds with the initial data packet (if applicable).
192+ - If no data packet is needed, state is changed to mscStateStatus and step 4 is skipped.
193+
194+ 4. The host acks the data packet and MSC calls m.scsiDataTransfer() to continue sending (or
195+ receiving) data.
196+ - This cycle continues until all data requested in the CBW is sent/received.
197+ - State is changed to mscStateStatus.
198+ - MSC waits for the host to ACK the final data packet.
199+
200+ 5. MSC then sends a CSW (Command Status Wrapper) to the host to report the final status of the
201+ command execution and moves to mscStateStatusSent.
202+
203+ 6. The host ACKs the CSW and the MSC moves back to mscStateCmd, waiting for the next CBW.
204+ */
178205func (m * msc ) run (b []byte , isEpOut bool ) {
179206 // TODO: Cleanup?
180207 if m .prevState != m .state {
You can’t perform that action at this time.
0 commit comments