maple serial on Android?

Post here first, or if you can't find a relevant section!
WindyYam
Posts: 31
Joined: Mon Aug 07, 2017 2:39 am

maple serial on Android?

Post by WindyYam » Fri Jan 26, 2018 2:48 am

I have some Blue pill projs run fine on pc , and now i have to do some interactivity with unity3d on android through serial interface. so question is, does maple serial directly acceptable on android(with otg) ? or does it need drivers like pc to be installed?

User avatar
mrburnette
Posts: 2190
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: maple serial on Android?

Post by mrburnette » Fri Jan 26, 2018 4:23 am

The bootloader appears to the host PC as a DFU device.

After a sketch is running, serial is enumerated as discussed here:
http://docs.leaflabs.com/static.leaflab ... oader.html
Newest bootloader includes a small "sketch" that loads into the program area so that the bootloader has a program into which the timeout will invoke & the PC will enumerate to a serial port ... assuming the drivers have been properly configured.

There is a HID library available, but no OTG on Maple Mini or blue pills (to my knowledge.)

Reference: http://www.emcu.it/STM32/STM32_USB_Devi ... t_OTG.html


Ray

WindyYam
Posts: 31
Joined: Mon Aug 07, 2017 2:39 am

Re: maple serial on Android?

Post by WindyYam » Fri Jan 26, 2018 4:44 am

thanks for the reply, what i want to do is access the maple serial usb from Android(unity3d). the blue pill send quaternion data out to usb serial. it's ok on pc processing 3d visualize, but i have to run that on unity with android. after some google i dont find useful information (for unity mono)

ag123
Posts: 854
Joined: Thu Jul 21, 2016 4:24 pm

Re: maple serial on Android?

Post by ag123 » Fri Jan 26, 2018 8:46 am

i'm not familar with unity3d hence won't be able to comment about it.
but in general to make android talk usb-serial, you probably need something like this:
https://github.com/felHR85/UsbSerial

i'd think it should work e.g. the above UsbSerial for android and maple/BP, but havn't tried it myself
another thing would be that OTG from a phone is possibly low/under powered and you may need to feed power directly to the maple/BP in addition

User avatar
mrburnette
Posts: 2190
Joined: Mon Apr 27, 2015 12:50 pm
Location: Greater Atlanta
Contact:

Re: maple serial on Android?

Post by mrburnette » Fri Jan 26, 2018 1:48 pm

WindyYam wrote:
Fri Jan 26, 2018 4:44 am
thanks for the reply, what i want to do is access the maple serial usb from Android(unity3d). the blue pill send quaternion data out to usb serial. it's ok on pc processing 3d visualize, but i have to run that on unity with android. after some google i dont find useful information (for unity mono)
So, where does OTG come into play? As stated, I do not believe you will get a blue pill to OTG.
Connecting an Android tablet or smartphone over serial is another matter... http://stm32duino.com/viewtopic.php?f=45&t=767

csnol
Posts: 31
Joined: Thu Aug 24, 2017 12:57 pm

Re: maple serial on Android?

Post by csnol » Fri Jan 26, 2018 6:14 pm

Suggestions:
1. Need a USB-TTL adapter for Android OTG >> USB-TTL >> BluePill (PA9 PA10 or other pins) serial communication,
2. change to STM32F107 or others STM32 MCU which native support USB port.
3. unity3d support HTML5 and WEB, you can use WiFi2Serial modules (ESP8266 or ESP32) to control STM32 or replace it directly.
4. Any Tiny LinuxARM boards (Raspberry Zero) >> Android OTG, the Serial and USB is easy to controlled on Linux.

BTW, Just wonder for it , Why use the Serial Interface for Android project and don't use USB and WiFi even BLE? . so many MCUs native support.

User avatar
RogerClark
Posts: 7680
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: maple serial on Android?

Post by RogerClark » Fri Jan 26, 2018 9:03 pm

I have not looked at USB Serial on Android for some time, but on AVR boards I recall needing to use a separate library on Android to use USB Serial with the VID/PID even of the official Arduino AVR boards.

The LibMaple Core, implements the standard USB CDCACM Serial device, but the phone will not recognise the VID/PID identification numbers for Leaflabs, as I don’t know any OS which recognises the Maple without being told what driver to use.

If it’s a personal project, you could change the VID/PID numbers in the core, to match another device which Android knows is a USB CDCACM device ( but I don’t know what those values would be)

WindyYam
Posts: 31
Joined: Mon Aug 07, 2017 2:39 am

Re: maple serial on Android?

Post by WindyYam » Sat Jan 27, 2018 1:18 am

csnol wrote:
Fri Jan 26, 2018 6:14 pm
Why use the Serial Interface for Android project and don't use USB and WiFi even BLE? . so many MCUs native support.
because that's simple enough... I tried WiFi version with 8266, but that would be at the cost of the WiFi connection, and you always have to match the socket ip address/match the hotspot ssid, i don't know how to. BLE is okay, but I want my application to be able run on both PC and Android , many PC dont have BT. so that's why I use unity

WindyYam
Posts: 31
Joined: Mon Aug 07, 2017 2:39 am

Re: maple serial on Android?

Post by WindyYam » Sat Jan 27, 2018 1:50 am

OK forget about Android unity for a moment ...

I encountered a new problem, on PC unity.

the unity use .net api script so It's okay to call serial port. But, I found something different between Maple serial and Arduino UNO usb serial(ATMEGA16U2)

with Arduino UNO the serial packet is serial.ReadByte() , it blocks until data come, then run to the next line
with Maple serial the serial packet will block in serial.ReadByte() Forever, nothing comes

the samething happens on Matlab and Processing so I assume it's something more fundamental in driver or something. I recall my programming on Processing I have to call read in serialEvent in order not to block. i tried event handler in unity but nothing changes

ag123
Posts: 854
Joined: Thu Jul 21, 2016 4:24 pm

Re: maple serial on Android?

Post by ag123 » Sat Jan 27, 2018 5:28 am

i tend to use Serial.available() to check if there is data in the queue so that to an extent i did some kind of 'non-blocking' reads
viewtopic.php?f=18&t=2752

Code: Select all

if(Serial.available()) {
  while(Serial.available()) {
    char c = Serial.read();
    ...........
    }
}

Post Reply