4

Huawei E3531 の RSSI を読みたいです。そのため、AT コマンドを使用してこれらの情報を取得する簡単な方法を示すドキュメントをいくつか見つけました。問題は、Huawei E3531 にさえ接続できないことです。つまり、モデムとして非常にうまく機能します。私は良い接続を持っています。しかし、devでデバイスを探していると、2つのディスクのように見える2つのデバイス(「sdb」と「sgm」)しか見つかりませんが、シリアルポートとは関係ありません。

それで、私が見つけた何かを試してみました: -彼らは私が sudo modprobe usbserial vendor=0X"Idvendor" product=0X"Idproduct" を実行します

[ 1038.498282] usbcore: registered new interface driver usbserial
[ 1038.498299] usbcore: registered new interface driver usbserial_generic
[ 1038.498312] usbserial: USB Serial support registered for generic

通常、次のようなものが必要です。

usb 1-1: generic converter now attached to ttyUSB0

私のMacからsdbとsgmを見ることさえできなかったと言わなければならないと思うので、Ubuntuからこれをやっています。また、wifi を有効にすると、モデムが接続できません (そのため、sdb と sgm が表示されません)。

必要な場合は、dmesg の最初の部分を以下に示します。

[  742.756888] usb 3-1: USB disconnect, device number 6
[  743.123706] usb 3-1: new high-speed USB device number 7 using xhci_hcd
[  743.252854] usb 3-1: New USB device found, idVendor=12d1, idProduct=14dc
[  743.252861] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  743.252865] usb 3-1: Product: HUAWEI Mobile
[  743.252868] usb 3-1: Manufacturer: HUAWEI
[  743.482312] cdc_ether 3-1:1.0 usb0: register 'cdc_ether' at usb-0000:00:14.0-1, CDC Ethernet Device, 9a:c2:9b:ee:4c:d9
[  743.482859] usb-storage 3-1:1.2: USB Mass Storage device detected
[  743.483249] scsi11 : usb-storage 3-1:1.2
[  743.520839] audit: type=1400 audit(1427889713.269:79): apparmor="DENIED" operation="file_inherit" profile="/usr/lib/NetworkManager/nm-dhcp-client.action" pid=3414 comm="nm-dhcp-client." lport=29180 family="inet" sock_type="dgram" protocol=17
[  743.520857] audit: type=1400 audit(1427889713.269:80): apparmor="DENIED" operation="file_inherit" profile="/usr/lib/NetworkManager/nm-dhcp-client.action" pid=3414 comm="nm-dhcp-client." lport=47709 family="inet6" sock_type="dgram" protocol=17
[  744.481267] scsi 11:0:0:0: Direct-Access     HUAWEI   TF CARD Storage  2.31 PQ: 0 ANSI: 2
[  744.481722] sd 11:0:0:0: Attached scsi generic sg2 type 0
[  744.482933] sd 11:0:0:0: [sdb] Attached SCSI removable disk
[  753.752310] audit: type=1400 audit(1427889723.496:81): apparmor="DENIED" operation="file_inherit" profile="/usr/lib/NetworkManager/nm-dhcp-client.action" pid=3423 comm="nm-dhcp-client." lport=29180 family="inet" sock_type="dgram" protocol=17
[  753.752328] audit: type=1400 audit(1427889723.496:82): apparmor="DENIED" operation="file_inherit" profile="/usr/lib/NetworkManager/nm-dhcp-client.action" pid=3423 comm="nm-dhcp-client." lport=47709 family="inet6" sock_type="dgram" protocol=17
[ 1038.498282] usbcore: registered new interface driver usbserial
[ 1038.498299] usbcore: registered new interface driver usbserial_generic
[ 1038.498312] usbserial: USB Serial support registered for generic

またよろしくお願いします!また近いうちにお会いしましょう

EDIT 9/04/2015 だから私は何かを見つけました。lsusb を実行すると、デバイスが次のように表示されます。

バス 003 デバイス 020: ID 12d1:1f01 Huawei Technologies Co., Ltd.

1f01 は Idproduct ですが、モデムが独自に別のモードになるため、いつか変わる可能性があります。1F01 の場合は、次のようにします。

sudo usb_modeswitch -v 12d1 -p 1F01 -M '55534243123456780000000000000011062000000100000000000000000000' 

これにより、デバイスのモードが強制的に変更されます。これで、デバイスの Idproduct は 1001 になります。lsusb を実行して確認します。

バス 003 デバイス 023: ID 12d1:1001 Huawei Technologies Co., Ltd. E169/E620/E800 HSDPA モデム

また、USB0、USB1、USB2、USB3 の 4 つの新しい USB dev があります。minicom で AT コマンドを送信してみます。

4

1 に答える 1

5

基本的に、私の問題は、モデムがシリアルとして表示されないことでした。その方法を説明しましたが、次のコマンドでモデムを強制する必要があります。

sudo usb_modeswitch -v 12d1 -p 1F01 -M '5553424312345678000000000000001106200000010000000000000000000'

次に、Minicom を試してみました。これは非常に優れており、ボーレートやポートなどの適切なパラメーターを使用して適切に接続する必要があります。それを探して、いくつかのテストを行います。minicom で何を書いているかを確認するには、ローカル エコーを有効にするだけです (ctrl+a に続いて z でオプションを選択)。そのため、必要なすべての情報を送信できます。

しかし、私はそれをpythonスクリプトに統合したかったので、ここに私のコードがあります:

def terminalComAndRead(a,b) :
    found = False
    proc = subprocess.Popen([a], stdout=subprocess.PIPE, shell=True)#send the command
    (out, err) = proc.communicate()
    string=str(out)
    #print(string)
    foundstring=string.find(b, 0, len(string))#look for the string b in the serial answer of my device
    if foundstring != -1 :
        found= True #send back true if it found it
    return found

def send(data,ser):
    try:
        ser.write(data)#write the command my serail port
    except Exception as e:
        print "Couldn't send data to serial port: %s" % str(e)
    else:
        try:
            sleep(1)
            data = ser.read(1)#read the serial
        except Exception as e:
            print "Couldn't read data from serial port: %s" % str(e)
        else:
            if data:  # If data = None, timeout occurr
                n = ser.inWaiting()
                if n > 0: data += ser.read(n)
                return data

def searchModem():

    foundmob= False
    foundusb= False

    sudoPassword='Figaro5558_'#my sudo password
    command="usb_modeswitch -v 12d1 -p 1f01 -M '55534243123456780000000000000011062000000100000000000000000000'" # the command that for ce the modem to be on serial mode
    while foundusb!= True : # this allows me to look for the modem as an usb and then force it

        foundmob=terminalComAndRead("lsusb",'12d1:1f01')#doing a ls usb and then looking for the id of my device
        changemob=terminalComAndRead("lsusb",'12d1:1001')#this is the id of my device when it is already in serial mode

        if foundmob == True :
            sleep(1)
            os.system('echo %s|sudo -S %s' % (sudoPassword, command))# this is the line who execute the command on sudo

            foundusb=terminalComAndRead("ls /dev/ttyUSB*",'ttyUSB1')


        if changemob == True :
            foundusb=terminalComAndRead("ls /dev/ttyUSB*",'ttyUSB1')

        if foundusb == True :
                print('Modem ready for connection')

    ttyusb0=terminalComAndRead('dmesg | tail -50','now attached to ttyUSB0') #look int he dmesg if there is my new usb port

    if ttyusb0 == True :
        usbPort='/dev/ttyUSB0'#give the path 

    return usbPort

ser = serial.Serial(usbPort, 9600, bytesize=8, parity='N', stopbits=1, timeout=1, rtscts=False, dsrdtr=False) #connect to your serial

cmd="AT^HCSQ?\r\n"#the AT command
msg=str(send(cmd,ser))#use the send function to send the AT command
print(msg)

これは私にとってはうまくいきました。乾杯

于 2015-04-16T09:11:54.067 に答える