Skip to content

UploadResult#updated_upload_port might be missing from the UploadResponse #2287

Closed as not planned
@kittaakos

Description

@kittaakos

Describe the problem

During the upload to a board, the port might change. After #2253, the CLI can detect it and provide this information to clients. As requested at #2253 (review), the upload port must always be set whether it has changed or not. Sometimes it's missing.

To reproduce

I could reproduce when the port was missing using the command line way of the CLI:

./arduino-cli version
arduino-cli  Version: 0.34.0 Commit: 304d48cd Date: 2023-08-22T15:54:20Z
cat ~/Documents/Arduino/minimal/minimal.ino 
void setup() {}
void loop() {}
./arduino-cli board list 
Port                            Protocol Type              Board Name          FQBN                        Core             
/dev/cu.BLTH                    serial   Serial Port       Unknown                                                          
/dev/cu.Bluetooth-Incoming-Port serial   Serial Port       Unknown                                                          
/dev/cu.usbmodem14201           serial   Serial Port (USB) Arduino MKR1000     arduino:samd:mkr1000        arduino:samd     
/dev/cu.usbmodem14301           serial   Serial Port (USB) Arduino Uno         arduino:avr:uno             arduino:avr      
/dev/cu.usbmodem5               serial   Serial Port (USB) Arduino Nano 33 BLE arduino:mbed_nano:nano33ble arduino:mbed_nano
./arduino-cli compile -b arduino:mbed_nano:nano33ble ~/Documents/Arduino/minimal
Sketch uses 84080 bytes (8%) of program storage space. Maximum is 983040 bytes.
Global variables use 43968 bytes (16%) of dynamic memory, leaving 218176 bytes for local variables. Maximum is 262144 bytes.

Used platform     Version Path                                                                      
arduino:mbed_nano 4.0.4   /Users/a.kitta/Library/Arduino15/packages/arduino/hardware/mbed_nano/4.0.4

🐛 It fails with Arduino Nano 33 BLE:

./arduino-cli upload -b arduino:mbed_nano:nano33ble -p /dev/cu.usbmodem5 ~/Documents/Arduino/minimal --format json
{
  "stdout": "Device       : nRF52840-QIAA\nVersion      : Arduino Bootloader (SAM-BA extended) 2.0 [Arduino:IKXYZ]\nAddress      : 0x0\nPages        : 256\nPage Size    : 4096 bytes\nTotal Size   : 1024KB\nPlanes       : 1\nLock Regions : 0\nLocked       : none\nSecurity     : false\nErase flash\n\nDone in 0.001 seconds\nWrite 84088 bytes to flash (21 pages)\n\r[                              ] 0% (0/21 pages)\r[=                             ] 4% (1/21 pages)\r[==                            ] 9% (2/21 pages)\r[====                          ] 14% (3/21 pages)\r[=====                         ] 19% (4/21 pages)\r[=======                       ] 23% (5/21 pages)\r[========                      ] 28% (6/21 pages)\r[==========                    ] 33% (7/21 pages)\r[===========                   ] 38% (8/21 pages)\r[============                  ] 42% (9/21 pages)\r[==============                ] 47% (10/21 pages)\r[===============               ] 52% (11/21 pages)\r[=================             ] 57% (12/21 pages)\r[==================            ] 61% (13/21 pages)\r[====================          ] 66% (14/21 pages)\r[=====================         ] 71% (15/21 pages)\r[======================        ] 76% (16/21 pages)\r[========================      ] 80% (17/21 pages)\r[=========================     ] 85% (18/21 pages)\r[===========================   ] 90% (19/21 pages)\r[============================  ] 95% (20/21 pages)\r[==============================] 100% (21/21 pages)\nDone in 3.335 seconds\n",
  "stderr": ""
}
./arduino-cli compile -b arduino:avr:uno ~/Documents/Arduino/minimal
Sketch uses 444 bytes (1%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.

Used platform Version Path                                                                
arduino:avr   1.8.6   /Users/a.kitta/Library/Arduino15/packages/arduino/hardware/avr/1.8.6

✅ It works with Arduino Uno:

./arduino-cli upload -b arduino:avr:uno -p /dev/cu.usbmodem14301 ~/Documents/Arduino/minimal --format json
{
  "stdout": "",
  "stderr": "",
  "updated_upload_port": {
    "address": "/dev/cu.usbmodem14301",
    "label": "/dev/cu.usbmodem14301",
    "protocol": "serial",
    "protocol_label": "Serial Port (USB)",
    "properties": {
      "pid": "0x0043",
      "serialNumber": "75830303934351618212",
      "vid": "0x2341"
    },
    "hardware_id": "75830303934351618212"
  }
}

Expected behavior

updated_upload_port is always part of the response.

Arduino CLI version

0.34.0

Operating system

macOS

Operating system version

13.5

Additional context

I ran into a runtime error in IDE2. I am on a branch and working on new things. Hence, the breaking change can be IDE2. During debugging, I've seen partial Port objects with only the protocol and address properties via gRPC. The two things could be unrelated. However, the upload response was: {} log suggests the missing UploadResult message from the response.

2023-08-30T12:19:14.292Z root ERROR Request upload failed with error: Could not detect the port after the upload. Upload options were: {"sketch":{"name":"monitor3","uri":"file:///Users/a.kitta/Documents/Arduino/monitor3","mainFileUri":"file:///Users/a.kitta/Documents/Arduino/monitor3/monitor3.ino","otherSketchFileUris":[],"additionalFileUris":[],"rootFolderFileUris":[],"mtimeMs":1690878810006.6304},"fqbn":"arduino:mbed_nano:nano33ble","port":{"address":"/dev/cu.usbmodem14101","addressLabel":"/dev/cu.usbmodem14101","protocol":"serial","protocolLabel":"Serial Port (USB)","properties":{"pid":"0x805A","serialNumber":"131B9378799A643D","vid":"0x2341"},"hardwareId":"131B9378799A643D"},"verbose":true,"verify":false,"userFields":[],"progressId":"kba84zgl-6"}, upload response was: {} Error: Could not detect the port after the upload. Upload options were: {"sketch":{"name":"monitor3","uri":"file:///Users/a.kitta/Documents/Arduino/monitor3","mainFileUri":"file:///Users/a.kitta/Documents/Arduino/monitor3/monitor3.ino","otherSketchFileUris":[],"additionalFileUris":[],"rootFolderFileUris":[],"mtimeMs":1690878810006.6304},"fqbn":"arduino:mbed_nano:nano33ble","port":{"address":"/dev/cu.usbmodem14101","addressLabel":"/dev/cu.usbmodem14101","protocol":"serial","protocolLabel":"Serial Port (USB)","properties":{"pid":"0x805A","serialNumber":"131B9378799A643D","vid":"0x2341"},"hardwareId":"131B9378799A643D"},"verbose":true,"verify":false,"userFields":[],"progressId":"kba84zgl-6"}, upload response was: {}
    at CoreServiceImpl.upload (/Users/a.kitta/dev/git/arduino-ide/arduino-ide-extension/lib/node/core-service-impl.js:165:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async RpcProxyFactory.onRequest (/Users/a.kitta/dev/git/arduino-ide/node_modules/@theia/core/lib/common/messaging/proxy-factory.js:134:24)
    at async RpcProtocol.handleRequest (/Users/a.kitta/dev/git/arduino-ide/node_modules/@theia/core/lib/common/message-rpc/rpc-protocol.js:171:28)

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the nightly build
  • My report contains all necessary details

Metadata

Metadata

Assignees

Labels

topic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions