pwitab / nbiot

NB IoT Scanner
BSD 3-Clause "New" or "Revised" License
3 stars 2 forks source link

Error: could not open port #2

Closed drgagi closed 4 years ago

drgagi commented 4 years ago

$ nbiot --port 14 connect Error: could not open port '14': FileNotFoundError(2, 'The system cannot find the file specified.', None, 2)

My device is using port 14 and can connect with putty serial.

Krolken commented 4 years ago

It might be that your port is named differently on system level.

Are you on Linux/MAc or Windows?

on Linux/mac you run

ls /dev/tty*

to list your available ports.

drgagi commented 4 years ago

Windows 10, it is COM port 14 listed in device manager.

drgagi commented 4 years ago

I tried on Ubuntu, passed connection part but failed on some point with cause "Error on AT Command":

Connecting to network... [2020-07-02 19:46:32,720] :: [DEBUG] :: nbiot.module :: Applying AT Command: AT+CGPADDR [2020-07-02 19:46:32,744] :: [DEBUG] :: nbiot.module :: Sent: b'AT+CGPADDR\r\n' [2020-07-02 19:46:32,745] :: [DEBUG] :: nbiot.module :: Recieved ack: b'\r\n' [2020-07-02 19:46:32,766] :: [DEBUG] :: nbiot.module :: Processing URC: +CGPADDR: 0 [2020-07-02 19:46:32,766] :: [INFO] :: nbiot.module :: Updated the IP Address of the module to +CGPADDR: [2020-07-02 19:46:32,766] :: [DEBUG] :: nbiot.module :: Received: [b'+CGPADDR: 0', b'OK'] [2020-07-02 19:46:32,766] :: [DEBUG] :: nbiot.module :: AT Command response = [] [2020-07-02 19:46:32,767] :: [DEBUG] :: nbiot.module :: Applying AT Command: AT+CGDCONT? [2020-07-02 19:46:32,790] :: [DEBUG] :: nbiot.module :: Sent: b'AT+CGDCONT?\r\n' [2020-07-02 19:46:32,790] :: [DEBUG] :: nbiot.module :: Recieved ack: b'\r\n' [2020-07-02 19:46:32,822] :: [DEBUG] :: nbiot.module :: Processing URC: +CGDCONT: 0,"IP",,,0,0,,,,,1 [2020-07-02 19:46:32,826] :: [DEBUG] :: nbiot.module :: Received: [b'+CGDCONT: 0,"IP",,,0,0,,,,,1', b'OK'] [2020-07-02 19:46:32,826] :: [DEBUG] :: nbiot.module :: AT Command response = [] [2020-07-02 19:46:32,826] :: [DEBUG] :: nbiot.module :: Applying AT Command: AT+CEREG? [2020-07-02 19:46:32,850] :: [DEBUG] :: nbiot.module :: Sent: b'AT+CEREG?\r\n' [2020-07-02 19:46:32,850] :: [DEBUG] :: nbiot.module :: Recieved ack: b'\r\n' [2020-07-02 19:46:32,871] :: [DEBUG] :: nbiot.module :: Processing URC: +CEREG: 1,0 [2020-07-02 19:46:32,871] :: [INFO] :: nbiot.module :: Updated status EPS Registration = 0 [2020-07-02 19:46:32,872] :: [DEBUG] :: nbiot.module :: Received: [b'+CEREG: 1,0', b'OK'] [2020-07-02 19:46:32,872] :: [DEBUG] :: nbiot.module :: AT Command response = [] [2020-07-02 19:46:32,872] :: [DEBUG] :: nbiot.module :: Applying AT Command: AT+CGSN=1 [2020-07-02 19:46:32,896] :: [DEBUG] :: nbiot.module :: Sent: b'AT+CGSN=1\r\n' [2020-07-02 19:46:32,896] :: [DEBUG] :: nbiot.module :: Recieved ack: b'\r\n' [2020-07-02 19:46:32,917] :: [DEBUG] :: nbiot.module :: Processing URC: +CGSN: 357518080043573 [2020-07-02 19:46:32,922] :: [DEBUG] :: nbiot.module :: Received: [b'+CGSN: 357518080043573', b'OK'] [2020-07-02 19:46:32,922] :: [DEBUG] :: nbiot.module :: AT Command response = [] [2020-07-02 19:46:32,922] :: [DEBUG] :: nbiot.module :: Applying AT Command: AT+CSCON=1 [2020-07-02 19:46:32,943] :: [DEBUG] :: nbiot.module :: Sent: b'AT+CSCON=1\r\n' [2020-07-02 19:46:32,944] :: [DEBUG] :: nbiot.module :: Recieved ack: b'\r\n' [2020-07-02 19:46:32,965] :: [DEBUG] :: nbiot.module :: Received: [b'OK'] [2020-07-02 19:46:32,965] :: [DEBUG] :: nbiot.module :: AT Command response = [] [2020-07-02 19:46:32,965] :: [INFO] :: nbiot.module :: Signaling Connection URC enabled [2020-07-02 19:46:32,965] :: [DEBUG] :: nbiot.module :: Applying AT Command: AT+CEREG=1 [2020-07-02 19:46:32,990] :: [DEBUG] :: nbiot.module :: Sent: b'AT+CEREG=1\r\n' [2020-07-02 19:46:32,990] :: [DEBUG] :: nbiot.module :: Recieved ack: b'\r\n' [2020-07-02 19:46:33,010] :: [DEBUG] :: nbiot.module :: Received: [b'OK'] [2020-07-02 19:46:33,011] :: [DEBUG] :: nbiot.module :: AT Command response = [] [2020-07-02 19:46:33,011] :: [INFO] :: nbiot.module :: Network registration enabled [2020-07-02 19:46:33,011] :: [DEBUG] :: nbiot.module :: Applying AT Command: AT+CFUN=1 [2020-07-02 19:46:33,036] :: [DEBUG] :: nbiot.module :: Sent: b'AT+CFUN=1\r\n' [2020-07-02 19:46:33,059] :: [DEBUG] :: nbiot.module :: Recieved ack: b'\r\n' [2020-07-02 19:46:33,080] :: [DEBUG] :: nbiot.module :: Processing URC: +CEREG: 0 [2020-07-02 19:46:33,080] :: [INFO] :: nbiot.module :: Updated status EPS Registration = 0 Traceback (most recent call last): File "/usr/local/bin/nbiot", line 11, in load_entry_point('nbiot==0.0.1.dev0', 'console_scripts', 'nbiot')() File "/usr/local/lib/python3.8/dist-packages/nbiot-0.0.1.dev0-py3.8.egg/nbiot/init.py", line 69, in main cli() File "/usr/local/lib/python3.8/dist-packages/click-7.1.2-py3.8.egg/click/core.py", line 829, in call return self.main(args, kwargs) File "/usr/local/lib/python3.8/dist-packages/click-7.1.2-py3.8.egg/click/core.py", line 782, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.8/dist-packages/click-7.1.2-py3.8.egg/click/core.py", line 1259, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.8/dist-packages/click-7.1.2-py3.8.egg/click/core.py", line 1066, in invoke return ctx.invoke(self.callback, ctx.params) File "/usr/local/lib/python3.8/dist-packages/click-7.1.2-py3.8.egg/click/core.py", line 610, in invoke return callback(args, *kwargs) File "/usr/local/lib/python3.8/dist-packages/click-7.1.2-py3.8.egg/click/decorators.py", line 33, in new_func return f(get_current_context().obj, args, **kwargs) File "/usr/local/lib/python3.8/dist-packages/nbiot-0.0.1.dev0-py3.8.egg/nbiot/scan.py", line 34, in connect connect_module(module, app_ctx) File "/usr/local/lib/python3.8/dist-packages/nbiot-0.0.1.dev0-py3.8.egg/nbiot/scan.py", line 17, in connect_module module.enable_radio_functions() File "/usr/local/lib/python3.8/dist-packages/nbiot-0.0.1.dev0-py3.8.egg/nbiot/module.py", line 187, in enable_radio_functions self._at_action(self.AT_ENABLE_ALL_RADIO_FUNCTIONS) File "/usr/local/lib/python3.8/dist-packages/nbiot-0.0.1.dev0-py3.8.egg/nbiot/module.py", line 345, in _at_action irc = self._read_line_until_contains('OK', timeout=timeout, File "/usr/local/lib/python3.8/dist-packages/nbiot-0.0.1.dev0-py3.8.egg/nbiot/module.py", line 436, in _read_line_until_contains raise ATError('Error on AT Command') nbiot.module.ATError: Error on AT Command

Krolken commented 4 years ago

OK. Your device responds with ERROR to the AT+CFUN=1 command. Not really sure why.

On windows don't you have to specify COM14 and not just 14

drgagi commented 4 years ago

SIM contact was not ok so module could not detect sim card and that was the reason why it fails. Maybe you can add one more check for this. Try AT+CIMI which return IMSI number located on SIM card. If this command returns error it means no sim card inserted or connectors are bad so module can not detect sim. You can add this as warning. Anyway I succeed to make connection, I got IP address and everything loos fine but script stooped on "Awaiting Connection". What exactly script is waiting for?

Connecting to network... [2020-07-02 22:27:11,639] :: [DEBUG] :: nbiot.module :: Applying AT Command: AT+CGPADDR [2020-07-02 22:27:11,663] :: [DEBUG] :: nbiot.module :: Sent: b'AT+CGPADDR\r\n' [2020-07-02 22:27:11,663] :: [DEBUG] :: nbiot.module :: Recieved ack: b'\r\n' [2020-07-02 22:27:11,694] :: [DEBUG] :: nbiot.module :: Processing URC: +CGPADDR: 0,"10.245.145.229" [2020-07-02 22:27:11,694] :: [INFO] :: nbiot.module :: Updated the IP Address of the module to 10.245.145.229 [2020-07-02 22:27:11,700] :: [DEBUG] :: nbiot.module :: Received: [b'+CGPADDR: 0,"10.245.145.229"', b'OK'] [2020-07-02 22:27:11,700] :: [DEBUG] :: nbiot.module :: AT Command response = [] [2020-07-02 22:27:11,700] :: [DEBUG] :: nbiot.module :: Applying AT Command: AT+CGDCONT? [2020-07-02 22:27:11,724] :: [DEBUG] :: nbiot.module :: Sent: b'AT+CGDCONT?\r\n' [2020-07-02 22:27:11,726] :: [DEBUG] :: nbiot.module :: Recieved ack: b'\r\n' [2020-07-02 22:27:11,764] :: [DEBUG] :: nbiot.module :: Processing URC: +CGDCONT: 0,"IP","vip.iot",,0,0,,,,,0 [2020-07-02 22:27:11,772] :: [DEBUG] :: nbiot.module :: Received: [b'+CGDCONT: 0,"IP","vip.iot",,0,0,,,,,0', b'OK'] [2020-07-02 22:27:11,772] :: [DEBUG] :: nbiot.module :: AT Command response = [] [2020-07-02 22:27:11,772] :: [DEBUG] :: nbiot.module :: Applying AT Command: AT+CEREG? [2020-07-02 22:27:11,797] :: [DEBUG] :: nbiot.module :: Sent: b'AT+CEREG?\r\n' [2020-07-02 22:27:11,797] :: [DEBUG] :: nbiot.module :: Recieved ack: b'\r\n' [2020-07-02 22:27:11,818] :: [DEBUG] :: nbiot.module :: Processing URC: +CEREG: 1,1 [2020-07-02 22:27:11,818] :: [INFO] :: nbiot.module :: Updated status EPS Registration = 1 [2020-07-02 22:27:11,819] :: [DEBUG] :: nbiot.module :: Received: [b'+CEREG: 1,1', b'OK'] [2020-07-02 22:27:11,819] :: [DEBUG] :: nbiot.module :: AT Command response = [] [2020-07-02 22:27:11,819] :: [DEBUG] :: nbiot.module :: Applying AT Command: AT+CGSN=1 [2020-07-02 22:27:11,843] :: [DEBUG] :: nbiot.module :: Sent: b'AT+CGSN=1\r\n' [2020-07-02 22:27:11,844] :: [DEBUG] :: nbiot.module :: Recieved ack: b'\r\n' [2020-07-02 22:27:11,867] :: [DEBUG] :: nbiot.module :: Processing URC: +CGSN: 357518080043573 [2020-07-02 22:27:11,873] :: [DEBUG] :: nbiot.module :: Received: [b'+CGSN: 357518080043573', b'OK'] [2020-07-02 22:27:11,873] :: [DEBUG] :: nbiot.module :: AT Command response = [] [2020-07-02 22:27:11,873] :: [DEBUG] :: nbiot.module :: Applying AT Command: AT+CSCON=1 [2020-07-02 22:27:11,897] :: [DEBUG] :: nbiot.module :: Sent: b'AT+CSCON=1\r\n' [2020-07-02 22:27:11,897] :: [DEBUG] :: nbiot.module :: Recieved ack: b'\r\n' [2020-07-02 22:27:11,918] :: [DEBUG] :: nbiot.module :: Received: [b'OK'] [2020-07-02 22:27:11,918] :: [DEBUG] :: nbiot.module :: AT Command response = [] [2020-07-02 22:27:11,918] :: [INFO] :: nbiot.module :: Signaling Connection URC enabled [2020-07-02 22:27:11,919] :: [DEBUG] :: nbiot.module :: Applying AT Command: AT+CEREG=1 [2020-07-02 22:27:11,945] :: [DEBUG] :: nbiot.module :: Sent: b'AT+CEREG=1\r\n' [2020-07-02 22:27:11,945] :: [DEBUG] :: nbiot.module :: Recieved ack: b'\r\n' [2020-07-02 22:27:11,966] :: [DEBUG] :: nbiot.module :: Received: [b'OK'] [2020-07-02 22:27:11,966] :: [DEBUG] :: nbiot.module :: AT Command response = [] [2020-07-02 22:27:11,966] :: [INFO] :: nbiot.module :: Network registration enabled [2020-07-02 22:27:11,966] :: [DEBUG] :: nbiot.module :: Applying AT Command: AT+CFUN=1 [2020-07-02 22:27:11,992] :: [DEBUG] :: nbiot.module :: Sent: b'AT+CFUN=1\r\n' [2020-07-02 22:27:11,992] :: [DEBUG] :: nbiot.module :: Recieved ack: b'\r\n' [2020-07-02 22:27:12,014] :: [DEBUG] :: nbiot.module :: Received: [b'OK'] [2020-07-02 22:27:12,014] :: [DEBUG] :: nbiot.module :: AT Command response = [] [2020-07-02 22:27:12,014] :: [INFO] :: nbiot.module :: All radio functions enabled [2020-07-02 22:27:12,014] :: [DEBUG] :: nbiot.module :: Applying AT Command: AT+CPSMS=0 [2020-07-02 22:27:12,040] :: [DEBUG] :: nbiot.module :: Sent: b'AT+CPSMS=0\r\n' [2020-07-02 22:27:12,040] :: [DEBUG] :: nbiot.module :: Recieved ack: b'\r\n' [2020-07-02 22:27:12,061] :: [DEBUG] :: nbiot.module :: Received: [b'OK'] [2020-07-02 22:27:12,061] :: [DEBUG] :: nbiot.module :: AT Command response = [] [2020-07-02 22:27:12,061] :: [DEBUG] :: nbiot.module :: Applying AT Command: AT+NPSMR=0 [2020-07-02 22:27:12,086] :: [DEBUG] :: nbiot.module :: Sent: b'AT+NPSMR=0\r\n' [2020-07-02 22:27:12,086] :: [DEBUG] :: nbiot.module :: Recieved ack: b'\r\n' [2020-07-02 22:27:12,110] :: [DEBUG] :: nbiot.module :: Received: [b'OK'] [2020-07-02 22:27:12,111] :: [DEBUG] :: nbiot.module :: AT Command response = [] [2020-07-02 22:27:12,111] :: [INFO] :: nbiot.module :: Disabled Power Save Mode [2020-07-02 22:27:12,111] :: [INFO] :: nbiot.module :: Trying to connect to operator 22005 network [2020-07-02 22:27:12,111] :: [DEBUG] :: nbiot.module :: Applying AT Command: AT+COPS=1,2,"22005" [2020-07-02 22:27:12,136] :: [DEBUG] :: nbiot.module :: Sent: b'AT+COPS=1,2,"22005"\r\n' [2020-07-02 22:27:12,142] :: [DEBUG] :: nbiot.module :: Recieved ack: b'\r\n' [2020-07-02 22:27:12,168] :: [DEBUG] :: nbiot.module :: Received: [b'OK'] [2020-07-02 22:27:12,168] :: [DEBUG] :: nbiot.module :: AT Command response = [] [2020-07-02 22:27:12,168] :: [INFO] :: root :: Awaiting Connection

drgagi commented 4 years ago

I add --home-network at it works. Thank you.

Krolken commented 4 years ago

Perfect. Yeah home-network vs roaming can be a bit annoying. First I only had foreign SIMs that required roaming and then I had to implement the home-network since I got Swedish SIMs.