Kotlin 101: How to communicate via Serial Connection Part 2

Поділитися
Вставка
  • Опубліковано 11 січ 2025

КОМЕНТАРІ • 40

  • @thijspirmez369
    @thijspirmez369 2 роки тому +4

    Thank you for the good tutorial! Note to viewers that use this tutorial at a later time and targeting Android 12 or higher: Your app will crash if you set your PendingIntent flag to "0" in the startUsbConnecting() function. Instead use:
    val intent: PendingIntent = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
    PendingIntent.getBroadcast(this, 0, Intent(ACTION_USB_PERMISSION),
    FLAG_MUTABLE)
    } else {
    PendingIntent.getBroadcast(this, 0, Intent(ACTION_USB_PERMISSION),
    0)
    }

  • @Candycab123
    @Candycab123 5 років тому +14

    Very good videos. But please do a follow up video on how to read from serial.. Have been waiting a long time now... 🙂 Keep up the good work!! 👍👍👍

    • @ivgmu
      @ivgmu 3 роки тому +1

      Yes, please!

  • @technomech303
    @technomech303 3 роки тому +4

    Excellent video. But it only explains how to send data through the connected USB device. I would very much like for you to explain how to also receive data. Any clues on that?

  • @useruiiijjjjhhhhh
    @useruiiijjjjhhhhh Рік тому

    Thank you for the tutorial, but how to read / write can bus protocol? Would be the same?

  • @vitormcbarros
    @vitormcbarros 4 роки тому +5

    To add Serial read:
    Add this callback:
    var mCallback = UsbReadCallback { data: ByteArray? ->
    val dataStr = data.toString()
    Log.i("Serial", "Data received: " + dataStr)
    }
    And add this line:
    m_serial!!.read(mCallback)
    after this line:
    m_serial!!.setFlowControl(UsbSerialInterface.FLOW_CONTROL_OFF)

    • @blakegover5161
      @blakegover5161 4 роки тому

      I am new at this but, this appears to only receive one byte from the serial port, what if we are trying to receive 8195 bytes at a time. What about len = m_serial!!.read(buf , timeout) how do we implement that? Adding a read operation has been a challenge. BTW - Thank you for this video it's been a great help. For sending one byte I think this works also, m_serial!!.write("0x50".toByteArray()). I struggled with getting a 1 byte Array to work.

  • @Gnarchoi
    @Gnarchoi 6 років тому +3

    Hi, I recently have been following this tutorial series. It has proven very helpful, but how can I verify that I am opening the right port. Such as ttyl1 or ttyl3 serial ports from my device. Also how can I verify that I am sending data such as sending a simple "Hello World" from my device to my serial console on my PC? Thanks in advance!

  • @robertbrown6176
    @robertbrown6176 5 років тому +1

    So its been six months since it was posted that a read data video was in the works, but its still not posted. What is the hold up? Pretty useless with a read ability

  • @TitiloTeam
    @TitiloTeam 6 років тому +3

    Please! Upload the serial read! Thanks a lot for the great work!

    • @apptaura8131
      @apptaura8131  6 років тому +4

      Hi Roberto, thanks for the comment. We have a tutorial for serial read in the pipeline and hope to have it released soon.

  • @bartekpoznan
    @bartekpoznan 5 років тому +3

    How About Serial Read It Possible?

  • @leonardobianco1307
    @leonardobianco1307 4 роки тому +1

    Friend how do we receive a string from the arduino, thanks

  • @Maflin18
    @Maflin18 3 роки тому

    Hello, could you please share the next steps? I followed instructions and have the app set up properly to connect and send data over USB, but send to what? How do I receive? Please show how you would set up something (like an arduino, for example) on the receiving end... thanks.

  • @sagardeshmukh1835
    @sagardeshmukh1835 2 роки тому

    Great work
    I have a different problem
    How can i connect and read and write data using RS232 cable

  • @affiliatecharisma7197
    @affiliatecharisma7197 5 років тому

    Is there a way to speed up the rate at which the data sends? My Arduino seems to respond slowly to turning on and off.

  • @alicentrale1914
    @alicentrale1914 4 роки тому

    is this library(USB Serial) work with java in android studio or just in Kotlin ??

  • @lawlrus1207
    @lawlrus1207 5 років тому

    hey guys, it's as simple as this for reading:
    m_serial.read(readCallback)
    private val readCallback = UsbSerialInterface.UsbReadCallback { bytes ->
    val string = bytes.toString(Charsets.UTF_8)
    }

    • @flavio5051
      @flavio5051 4 роки тому

      Hi JKevin, but where do I put thew. m_serial.read(readCallback) instruction? is the received data making an interruption or we need to poll for the data?
      thanks

  • @theclueless11212
    @theclueless11212 4 роки тому

    does this library only work for Kotlin? or can you use Java also?

  • @richardhargreaves8132
    @richardhargreaves8132 4 роки тому

    has anyone worked out how to do the read? the libary gives a java example I cant work out what the call back function should look in kotlin code

  • @untitled2792
    @untitled2792 4 роки тому

    Is there a way to get kotlin to read and display a live video signal using this?

  • @mustafagul4108
    @mustafagul4108 4 роки тому +1

    Thanks for usefull information. I want to send serial data to PC instead of Arduino. When I use this code, PC is not recognized as attached device. Is there a way to implement what I am looking for. I would appriciate any help :)

    • @sardorbekkhujaev7706
      @sardorbekkhujaev7706 4 роки тому

      Hello Mustafa!
      I have the same question. Did you solve it? How?

    • @gurkanucar
      @gurkanucar Рік тому

      hi, same question. Is there any solving?

  • @Joxsonw
    @Joxsonw 5 років тому

    "private fun & private val" isnt working on my android studio any clues?

  • @prod.dinamo7206
    @prod.dinamo7206 6 років тому +1

    Hello, great work.. but i have a question.. How i can read data from USB?? Please help...

    • @prod.dinamo7206
      @prod.dinamo7206 6 років тому

      How i use the callback??

    • @apptaura8131
      @apptaura8131  6 років тому +3

      Thanks for the comment. We're planning to address exactly that in a forthcoming video. Stay tuned!

    • @prod.dinamo7206
      @prod.dinamo7206 6 років тому

      Hello, so when you think that can upload the read video?? Please hurry... :)

    • @prod.dinamo7206
      @prod.dinamo7206 6 років тому

      Hello, i need your help.. i cannot implement the read function.. can you help me please?? my email is: power_arox@hotmail.com... please please...

    • @bartekpoznan
      @bartekpoznan 5 років тому

      ?@@prod.dinamo7206 have you done it

  • @babintandukar8917
    @babintandukar8917 4 роки тому

    i am still confused why the m_device is null ,
    how does it get instance of device to start connection from device list

    • @ahmetylmaz9909
      @ahmetylmaz9909 2 роки тому

      I connected only laptop to phone. m_device is null also for me. How did you solve this if you solved it? I am thinking to use my usb Hard disk drive with usb converter from type C. Maybe I can see my hdd.

  • @Mcantony007
    @Mcantony007 6 років тому

    How do i make it communicate in hexadecimal

  • @ahsimiksnabac6576
    @ahsimiksnabac6576 4 роки тому

    i am looking for someone to collaborate on a project. what we require is some expertise in getting an Arduino UNO board to communicate with a Android phone via USB (i.e. have the UNO trigger the Android to ring a stored number), not rocket science i know. the objective of the project is to have the UNO board monitor a series of vibration sensors, that bit has been sorted. when the vibe sens are tripped, the UNO communicates with the Android via USB and has it ring a stored number. its a cheep and cheerful bike alarm.

  • @steelakasteel7436
    @steelakasteel7436 Рік тому

    part 3?:)

  • @jmc_fpv
    @jmc_fpv 4 роки тому

    What about read?

  • @juliancaste3914
    @juliancaste3914 4 роки тому

    thank you

  • @HumanBeingSpawn
    @HumanBeingSpawn 2 роки тому

    4:41 LOL
    Stop it.