B4A Library Audio Serial Output library

Hello everyone, here's a library to send serial data using the Audio jack, i found this project here.
I decided to give it a shot and port that library to B4A, i haven't fully tested it, you should be able to send serial data over to a microcontroller, you can even use it with the arduino boards, i do not own an arduino board but if you're familiar with serial communication and microcontrollers you should be able to figure this out.
At the moment it is only possible to send data, not receive, the person who created this project is currently working on the receiving part, i will update this library once that part is accomplished.

you can download the library http://www.genesisitdevelopments.com/AudioSerial.zip
and here's an example: www.genesisitdevelopments.com/AudioSerialExample.zip

note that you can change the baudrate, as i mentioned above, i have not fully tested this library, but if you do i would like to hear some feedback.

Updated the link to download the library and the example, see above.

cheers,
Walter
 

Attachments

  • AudioSerial.zip
    51.9 KB · Views: 750
  • AudioSerial Example.zip
    335.3 KB · Views: 761
Last edited:

gxlujd

Member
Licensed User
bug report

Hello everyone, here's a library to send serial data using the Audio jack, i found this project here.
I decided to give it a shot and port that library to B4A, i haven't fully tested it, you should be able to send serial data over to a microcontroller, you can even use it with the arduino boards, i do not own an arduino board but if you're familiar with serial communication and microcontrollers you should be able to figure this out.
At the moment it is only possible to send data, not receive, the person who created this project is currently working on the receiving part, i will update this library once that part is accomplished.

you can download the library View attachment 12328
and here's an example: View attachment 12329

note that you can change the baudrate, as i mentioned above, i have not fully tested this library, but if you do i would like to hear some feedback.

cheers,
Walter

hello walterf25, Your AudioSerial library is very good, but there was a bug in the library file, demo program for the first time to send data and after sending data is not the same, I listen to the phone's speaker to contrast. Any baud rate, so this set has nothing to do with the baud rate, I think it should be 'AudioSerial.output (txtbox.Text)'.
In addition, I ask 'AudioSerial.SerialDAC' how to use?
my phone is lenovo P700.;)
 

nicieri

Active Member
Licensed User
Hi, Anyone know how to read the data from audio jack?

How can i use the audio jack for reciving data??

some like credit card reader? or any device required?

Thanks
 

Zeev Goldstein

Active Member
Licensed User
hi

did anyone had any success reading data using this ?
i am trying to read a magnetic card but it crashes
 

Zeev Goldstein

Active Member
Licensed User
audio serial - does it work ?

hi,

downloaded and tried it, yes - had to remove the manifest and icon files from the jar

but

it seems not to work or at least i couldn't see any result

when trying to click the button it crashed

did anyone managed to use it ? or any other similar library ? i need an urgent solution to read a magnetic card using an audio plug card reader (reader plugs to earphone jack)

thanks
 

raphaelcno

Active Member
Licensed User
did anyone managed to use it ? or any other similar library ? i need an urgent solution to read a magnetic card using an audio plug card reader (reader plugs to earphone jack)

As I understand from the first post, the library can be used to send serial data, not to receive data. So I think it will be difficult to read a card or anything else with this library.

Do you have a link to a datasheet or user manual of this card reader?
 

Zeev Goldstein

Active Member
Licensed User
thanks for the reply
ok, got it.

i have a card reader that plugs to the earphone jack.
i know there are apps out there that reads the mag stripe through it for example credit card
this is what i am looking for
any ideas ?

thanks again
 

walterf25

Expert
Licensed User

ralphie911

Member
Licensed User
Single Channel output

I am planning on using the Headphone jack with this library.

Everything is working great but is it possible to restrict the output data to only the left or the right audio channel?
 

GKCS

Member
Licensed User
Hi Walter,

I am just "playing" around with this great little library. Together with a standard LM324N OpAmp and 2 simple resistors, all works perfect. Speed up to 9600 baud works stable without any issuues.

I know, there is an USB-FTDI Wrapper, or Bluetooth to RS232, to archieve a serial connection. But both of them do have its limits too. Either they require a minimum Android version (3.x) or you have to deal with a much more complext BT procedure until all works as it should. Also, many times a cable transmission is much more reliable than any wireless (BT) way. So, besides the mentioned USB/BT ways, this audio-serial library is a very easy to implement but yet stable way to connect nearly any Android device to external serial hardware.

There is still an open question for me. "extended ASCII" codes ...
Unfortunately, Android uses UTF-8 as encoding schema for strings. So, when using AudioSerial.output(String)
you are NOT able to send plain extended ASCII characters, ASCII 128 to ASCII 255
B4A/Android always send this characters as 2 bytes UTF-8 encoded string.

Unfortunately, many external serial hardware will use the full 8bit ASCII range 0-255 ....

Question, is there any chance in the future, to change

AudioSerial.output(String) to
to
AudioSerial.output(BytesArray())

If using a Bytes Array, it seems that B4A can also transcode it to ISO-8859-1, which includes single bytes extended ASCII characters.

Many thanks for a great little library

Gerry
 

GKCS

Member
Licensed User
Hi Erel,
the issue is NOT, how to convert an existing String into a Byte-Array.
The issue is the STRING itself, which can't contain characters, encoded as extended ASCII codes.
This SerialAudio Library uses
AudioSerial.output(String) with STRING as parameter. That's why I ask, if there is any chance to change this parameter to
AudioSerial.output(ByteArray())
Only in this case, you would be able to send extended ASCII codes128 to 255. Otherwise, send as STRING, all extended ASCII codes are transmitted as 2Bytes UTF8 ....
Thanks a lot

Gerry
 

walterf25

Expert
Licensed User
Hi Walter,
Does the library work on the NXP Quick-Jack demo board?
Thanks
Hi Dale Lin, to be honest i'm not sure if it will work, i never tried it or even heard of this board until today, by looking at the schematic i could say it could work but i can't say for sure. If you decide to give it a try and it works please give us some feedback, i'm interested to know if it works.

Cheers,
Walter
 

walterf25

Expert
Licensed User
Almost all links are broken.
Also, is there way to make it two way? To add RX
This is an old library and I no longer maintain it, it was one of the first libraries I ever wrote when i started learning B4X, why not use a Bluetooth Library it seems to me it would be easier for serial communication, or do you really need to have hard wire serial communication?
 

hayk

Member
This is an old library and I no longer maintain it, it was one of the first libraries I ever wrote when i started learning B4X, why not use a Bluetooth Library it seems to me it would be easier for serial communication, or do you really need to have hard wire serial communication?
I want to make a chat through walkie talkies, using audio chanel. So this is better option.
 
Top