Page 1 of 1

USB TTL programming documentations

PostPosted: Fri Mar 25, 2016 1:37 am
by zsxking
Hi,

Is there any documentation of how to read data via USB TTL cable and write data to it? I want to write a server to use Raspberry Pi to monitor and control reefangel.

Thanks,

Re: USB TTL programming documentations

PostPosted: Fri Mar 25, 2016 9:48 am
by lnevo
It would be the same as the web protocol. You should be able to sens HTTP get's to the serial and you'd receive back the same output you'd get from a web request

Re: USB TTL programming documentations

PostPosted: Fri Mar 25, 2016 8:17 pm
by zsxking
Have you tried using USB TTL from a linux environment like from Raspberry Pi?

I was trying to use minicom to connect to it, but not seem to be able to communicate. My settings are
| A - Serial Device : /dev/ttyUSB0
| B - Lockfile Location : /var/lock
| C - Callin Program :
| D - Callout Program :
| E - Bps/Par/Bits : 57600 8N1
| F - Hardware Flow Control : No
| G - Software Flow Control : No

But it still Offline.

Re: USB TTL programming documentations

PostPosted: Sat Mar 26, 2016 9:39 am
by binder
try 115200 for the baud rate. I believe that is the default for it. (i may be wrong though)
i have a regular linux desktop environment working, so having it work on the pi should be doable.

Sent from my XT1585 using Tapatalk

Re: USB TTL programming documentations

PostPosted: Tue May 10, 2016 12:41 am
by zsxking
binder wrote:i have a regular linux desktop environment working, so having it work on the pi should be doable.


How do you develop in your linux environment?

Do I just write to the usb serial port like "GET /sa" then read from it? Don't have too much experience working with serial.

Would you mind provide a piece of code sample to read data from USB and print it as string on linux?

Re: USB TTL programming documentations

PostPosted: Tue May 10, 2016 4:37 am
by zsxking
If I keep listening to the serial port, I can get something like it occasionally:
GET /status/submitp.aspxt1=784&t2=761&t3=0&ph=794&id=zsxking&em=0&em1=0&rem=0&bid=1&key=&ddns=&af=0&sf=0&atohigh=0&atolow=0&r=209&ron=0&roff=255&pwma=0&pwmd=0&pwmao=255&pwmdo=255

But can't figure out how to request data actively.

Re: USB TTL programming documentations

PostPosted: Tue May 10, 2016 7:54 am
by lnevo
yes, that's the head unit sending out http requests to the wifi module.

you should be able to write GET /sa followed by two newlines, same as http protocol.

Re: USB TTL programming documentations

PostPosted: Tue May 10, 2016 6:53 pm
by binder
zsxking wrote:How do you develop in your linux environment?
I use CodeBlocks IDE for development of the libraries. I imported all the libraries and created my own workspace inside the app and I edit/write the code that way.
When testing the code on the controller, I just use the Arduino app. I use it to compile and upload the code.

I edit my INO files using the Arduino editor (or an external text editor) and the use it to compile and upload. This is most likely what you will be doing. Unless you are making changes to the libraries, you will just want to use the Arduino editor or whatever your favorite code/text editor.

Do I just write to the usb serial port like "GET /sa" then read from it? Don't have too much experience working with serial.
I just use the serial monitor that's built into the Arduino program. To get the status, yes, you would use "GET /sa ". When you are using the serial port and sending the commands, you MUST include a blank space at the end of the command. That is needed only when manually typing the commands in. If you use a web browser or one of the apps, you don't need that extra space.

Would you mind provide a piece of code sample to read data from USB and print it as string on linux?
See the previous question's reply. I use the Arduino environment so there's nothing extra or special that needs to be done other than using the serial monitor that's included with Arduino.