2017/7/18

CP2105 dual uart in one USB

http://community.silabs.com/t5/Interface/CP2105-driver-questions/td-p/89191

不用hub 哦,有linux driver.

kmesg
[20172.062093] usb 3-1.1: new full-speed USB device number 4 using xhci_hcd
[20172.164457] usb 3-1.1: New USB device found, idVendor=10c4, idProduct=ea70
[20172.164464] usb 3-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=5
[20172.164468] usb 3-1.1: Product: CP2105 Dual USB to UART Bridge Controller
[20172.164470] usb 3-1.1: Manufacturer: Silicon Labs
[20172.164473] usb 3-1.1: SerialNumber: 00775A41
[20172.232931] usbcore: registered new interface driver usbserial
[20172.232971] usbcore: registered new interface driver usbserial_generic
[20172.233003] usbserial: USB Serial support registered for generic
[20172.258589] usbcore: registered new interface driver cp210x
[20172.258646] usbserial: USB Serial support registered for cp210x
[20172.258718] cp210x 3-1.1:1.0: cp210x converter detected
[20172.342494] usb 3-1.1: reset full-speed USB device number 4 using xhci_hcd
[20172.443147] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8801bd4d3d48
[20172.443155] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8801bd4d3d00
[20172.443158] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8801bd4d35c8
[20172.443160] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8801bd4d3580
[20172.443879] usb 3-1.1: cp210x converter now attached to ttyUSB0
[20172.443955] cp210x 3-1.1:1.1: cp210x converter detected
[20172.444112] cp210x ttyUSB0: cp210x converter now disconnected from ttyUSB0
[20172.444145] cp210x 3-1.1:1.0: device disconnected
[20172.526619] usb 3-1.1: reset full-speed USB device number 4 using xhci_hcd
[20172.627173] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8801bd4d3d48
[20172.627182] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8801bd4d3d00
[20172.627185] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8801bd4d35c8
[20172.627188] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8801bd4d3580
[20172.627595] cp210x 3-1.1:1.0: cp210x converter detected
[20172.710760] usb 3-1.1: reset full-speed USB device number 4 using xhci_hcd
[20172.811375] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8801bd4d3d48
[20172.811383] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8801bd4d3d00
[20172.811387] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8801bd4d35c8
[20172.811390] xhci_hcd 0000:00:14.0: xHCI xhci_drop_endpoint called with disabled ep ffff8801bd4d3580
[20172.812071] usb 3-1.1: cp210x converter now attached to ttyUSB0
[20172.812417] usb 3-1.1: cp210x converter now attached to ttyUSB1
[20172.838229] cp210x ttyUSB1: failed to set baud rate to 300
cp2105 的datasheet
有兩個 port: enhanced, standard
Enhanced UART Interface Features

Data formats supported:
- Data bits: 5, 6, 7, and 8
- Stop bits: 1, 1.5, and 2
- Parity: odd, even, mark, space, no parity
Baud rates: 300 bps to 2.0 Mbps
320 Byte receive and transmit buffers
Two GPIO signals for status and control
RS-485 mode with bus transceiver control

Standard UART Interface Features

Data format: 8 data bits, 1 Stop bit
Parity: Even, Odd, No parity
Baud rates: 2400 bps to 921600 bps
288 Byte receive and transmit buffers
Three GPIO signals for status and control
果然enhanced 比較快,也可以必較慢。
-- 但是 ti 的 evb 卻選 standard port 為 data port....

Audio Latency and Roundtrip Delay

結果google 有 android audio latency.

Linux Alsa 有一個軟體測 roundtrip delay


2017/7/12

Android 6. external SD Card mount path

ref: AnExplorer

這是一個 file Explorer,會正確列出 SD Card 和 internal eMMC storage 的內容。
也會顯示 "SD Card" 和 "Internal Storage"

他得的方法是用 StorageManager 的 static function : "getVolumeList"
取得完整mount list,
然後一一取出 mount 資訊,再自己分類...

所以找得出 SD mount point..


另外... 這一篇的 sample function 可以正常動作。
其中的 function:
/* returns external storage paths (directory of external memory card) as array of Strings */
public String[] getExternalStorageDirectories() {

        List<String> results = new ArrayList<>();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { //Method 1 for KitKat & above
        File[] externalDirs = getExternalFilesDirs(null);

        for (File file : externalDirs) {
            String path = file.getPath().split("/Android")[0];

            boolean addPath = false;

            if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                addPath = Environment.isExternalStorageRemovable(file);
            }
            else{
                addPath = Environment.MEDIA_MOUNTED.equals(EnvironmentCompat.getStorageState(file));
            }

            if(addPath){
                results.add(path);
            }
        }
    }

        if(results.isEmpty()) { //Method 2 for all versions
            // better variation of: http://stackoverflow.com/a/40123073/5002496
            String output = "";
            try {
                final Process process = new ProcessBuilder().command("mount | grep /dev/block/vold")
                .redirectErrorStream(true).start();
                process.waitFor();
                final InputStream is = process.getInputStream();
                final byte[] buffer = new byte[1024];
                while (is.read(buffer) != -1) {
                    output = output + new String(buffer);
                }
                is.close();
            } catch (final Exception e) {
                e.printStackTrace();
            }
            if(!output.trim().isEmpty()) {
                String devicePoints[] = output.split("\n");
                for(String voldPoint: devicePoints) {
                    results.add(voldPoint.split(" ")[2]);
                }
            }
        }

        //Below few lines is to remove paths which may not be external memory card, like OTG (feel free to comment them out)
        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            for (int i = 0; i < results.size(); i++) {
                if (!results.get(i).toLowerCase().matches(".*[0-9a-f]{4}[-][0-9a-f]{4}")) {
                    Log.d(LOG_TAG, results.get(i) + " might not be extSDcard");
                    results.remove(i--);
                }
            }
        } else {
            for (int i = 0; i < results.size(); i++) {
                if (!results.get(i).toLowerCase().contains("ext") && !results.get(i).toLowerCase().contains("sdcard")) {
                    Log.d(LOG_TAG, results.get(i)+" might not be extSDcard");
                    results.remove(i--);
                }
            }
        }

        String[] storageDirectories = new String[results.size()];
        for(int i=0; i<results.size(); ++i) storageDirectories[i] = results.get(i);

        return storageDirectories;
    }

把他包起來放在 github 囉:https://github.com/checko/Getsdpath

2017/7/5

unionfs

ref:https://datahunter.org/unionfs
UnionFs 好像很有趣的,很像以前的 coda filesystem

是一種 layer 的概念: union folders
就是把 folder1 + folder2 加在一起變成 folderM,
然後 folderM 裡可以看到 folder1 和 folder2 的檔案。

然後不一樣的是...有layer 個概念:
folderM (f11,f12,f13,f21,f22,f23)
 |
 +--- folder2 (f21,f22,f23)
 |
 +--- folder1 (f11,f12,f13)
folderM


配上:http://www.linuxjournal.com/article/7714
可以把不同 filesystem 的folder 合在一起
-- 用 mount 的化,不同 filesystem 一定要不同 folder

另一個,好像是比較好(先進)的 unionfs 時做是 aufs
可以參考這篇 說明,在 linux 上試試看。