johnlauer/serial-port-json-server

How to use the serial JSON

Opened this issue · 27 comments

Hello,

I am new to communicating to serial port device, I am making a web application that communicates to a serial device, so I found your JSON Serial, I got the exe for windows, but unfortunately I don't know how to proceed ? what should I do to make a simple HTML page that receives data from the serial device ?

Thank you.
Regards,
Amira

If you look at the Readme there is a section called "Example Use Cases" and there are links to http://chilipeppr.com/serialport and a JSFiddle that shows how to talk to SPJS. What I would recommend as well is to watch some of the intro videos on ChiliPeppr to see how it uses SPJS. In fact, I link to a build video in the Readme and at the 19 minute mark I take a user through how to connect and use it. https://youtu.be/4Hou06bOuHc?t=1145

I did saw that section, I am sorry but I didn't get well if I can use the serial connection and data retrieval part without having to go into chilipepper, since I have the part of serial communication within my website, I don't want another website or tool to open up, I hope you get me , is this applicable with your tool ?

Yes, you can use this tool from any website as it just talks as a standard websocket. I recommend you just look at the JSFiddle and copy all of the code from it for your own site.

I am trying to set up a CNC controller for a UDOO dual. I have downloaded and installed serial-port-json-server_1.80_linux_arm7.tar.gz, untared it and tried to use it with chilipepper. However, I keep getting Serial-Port-JSON server disconnected. I can't seem to get it to connect to the built in arduino due on /dev/ttymxc3. I don't know where to change the /dev

Can you maybe post some screenshots?

Meaning, which workspace are you using inside ChiliPeppr? Are you just using the serialport workspace to get this going? There is no specific workspace for UDOO and no buffer flow algorithm in SPJS for UDOO, but that's all solvable with some extra work. So, screenshots would help me/us understand where you're running into trouble.

I am using ChiliPeppr/serialport. I see the /dev/ttymxc3 port when I
run serial-port-json-server. I tried to capture a screen shot in the
output.pdf file.

On 7/29/15, John Lauer notifications@github.com wrote:

Meaning, which workspace are you using inside ChiliPeppr? Are you just using
the serialport workspace to get this going? There is no specific workspace
for UDOO and no buffer flow algorithm in SPJS for UDOO, but that's all
solvable with some extra work. So, screenshots would help me/us understand
where you're running into trouble.


Reply to this email directly or view it on GitHub:
#21 (comment)

Kendall B. Green DC70FEBB

Not seeing any attachments. I think you need to paste directly into Github.

here is the screen.
serial-port-json-server

I would recommend you watch some of the videos on Youtube about ChiliPeppr to get a feel for this. There's over 60 videos.

You are halfway there. You don't seem to actually be connected to your Serial Port JSON Server from your browser in that screenshot. That's a fundamental here and if you watch some of the videos it could help you see that. Also, the text in the screenshot where it asks you to download explains that you have to do that as well.

I got the serial port json server connected v1.80 udoobuntu by setting
the PATH to include ur/local/go/bin setting a GOPATH to be
serial-port-json-server_1.80_linux_arm. The serial-port JSON window
says This widgit shows your available serial ports. It must be
connected to the local serial port Ajax server that chilipeppr
provides for linux. the IP address is 192.168.0.178

On 7/29/15, John Lauer notifications@github.com wrote:

I would recommend you watch some of the videos on Youtube about ChiliPeppr
to get a feel for this. There's over 60 videos.

You are halfway there. You don't seem to actually be connected to your
Serial Port JSON Server from your browser in that screenshot. That's a
fundamental here and if you watch some of the videos it could help you see
that. Also, the text in the screenshot where it asks you to download
explains that you have to do that as well.


Reply to this email directly or view it on GitHub:
#21 (comment)

Kendall B. Green DC70FEBB

Can you post a screenshot?

here is a screen print of chilipeppr/serialport
serialport

I tried the geturl?=http://davehylands.com/chilipepprlogo.nc and got
API error 1 (datastore_v3: BAD_REQUEST): Key path element must not be
incomplete: [DataUrlCache: ]

On 7/31/15, John Lauer notifications@github.com wrote:

Can you post a screenshot?


Reply to this email directly or view it on GitHub:
#21 (comment)

Kendall B. Green DC70FEBB

I updated to v1.83 but still get a message in the Chilipeppr Serial Port window:
Serial Port JSON Server v1.83 udoobuntu
Port List Your Servers
No serial ports found on your Serial Port JSON Server

I think the problem is that the list of serial ports does not include the UDOO serial port for the SAM3X chip, ttymxc3 It gets it list from /sys/device/platform/fsl-
the full list of devices is:
arm-pmu.0 imx-i2c.1 imx2-wdt.0 mxc_mipi_csi2 mxs$ enet.0 imx-i2c.2 imx_busfreq.0 mxc_pw$
Vivante GCCore fsl-ehci.0 imx-ipuv3.0 imx_dvfscore.0 mxc_pw$
alarmtimer fsl-ehci.1 imx-ocotp.0 imx_pm.0 mxc_sd$
anatop_reg.0 fsl-usb2-otg imx-pcm-audio.0 mxc_asrc.0 mxc_sd$
anatop_reg.1 fsl-usb2-udc imx-sdma mxc_hdmi mxc_v4$
anatop_reg.2 galcore.0 imx-ssi.0 mxc_hdmi_cec.0 mxc_v4$
anatop_reg.3 imx-fiq-pcm-audio.0 imx-uart.0 mxc_hdmi_core mxc_v4$
anatop_reg.4 imx-hdmi-soc-audio.0 imx-uart.1 mxc_hdmi_soc.0 mxc_vd$
anatop_reg.5 imx-hdmi-soc-dai.0 imx-uart.3 mxc_lcdif.0 mxc_vp$
anatop_thermal.0 imx-i2c.0 imx-vt1613.0 mxc_ldb mxs-dm$

Can you give a better background to all of this? Your setup sounds unique so it would help to describe the whole story behind it to help you. Is this an embedded machine? Is this a USB serial port? What's an UDOO? Can you provide more pictures/screenshots to be more descriptive?

Sure, the UDOO has a Freescale iMX6 CPU and a SAM3X arduino due chip.
It has HDMI, Ethernet, USB ports, Arduino R3 pins, I am currently
running Ubuntu 12.04 but will upgrade soon to 3.14 kernel. more info
is available at https://www.udoo.com/udoo-dual and quad.

I plan to get Chilipeppr, serial-port-json-server and TinyG2 running
together on the UDOO. Then I will get a gShield, hook it up to the
Arduino R3 pins. I will probably get a 3040 and replace its board
with the UDOO-gShield and hook up the motors and stops. I will
connect the UDOO to a touch screen monitor or a Motorola Lapdock. I
will have a small CNC mill to go with my 3D printer. Any suggestions
or comments?

On 8/2/15, John Lauer notifications@github.com wrote:

Can you give a better background to all of this? Your setup sounds unique so
it would help to describe the whole story behind it to help you. Is this an
embedded machine? Is this a USB serial port? What's an UDOO? Can you provide
more pictures/screenshots to be more descriptive?


Reply to this email directly or view it on GitHub:
#21 (comment)

Kendall B. Green DC70FEBB

Ok, so as far as I know the Due chip does not have a serial port on it. Rather it is native USB. The Arduino Due has an FTDI programmer port on it to solve for the initial programming of the SAM3X. Does the Udoo have that chip on it which should show up as a serial port? If you actually had TinyG G2 on the SAM3X then you'd have 2 further serial ports that would show up in SPJS. So, my gut is telling me you should be trying to find the FTDI programmer port. Or do they give you another way to flash the SAM3X?

The UDOO SAM3X can be flashed from a patched Arduino IDE or directly
using the serial port /dev/ttymxc3 using bossac. I believe that I
have flashed TinyG2 on it using bossac --port=ttymxc3 -U false -e -w
-v -b TinyG2.bin -R. It reported 500+ pages loaded and verified. Also
Tom Freudenberg has written a script called udoo-arduino-build which
will compile, build and flash arduino sketches from the UDOO command
line.

On 8/2/15, John Lauer notifications@github.com wrote:

Ok, so as far as I know the Due chip does not have a serial port on it.
Rather it is native USB. The Arduino Due has an FTDI programmer port on it
to solve for the initial programming of the SAM3X. Does the Udoo have that
chip on it which should show up as a serial port? If you actually had TinyG
G2 on the SAM3X then you'd have 2 further serial ports that would show up in
SPJS. So, my gut is telling me you should be trying to find the FTDI
programmer port. Or do they give you another way to flash the SAM3X?


Reply to this email directly or view it on GitHub:
#21 (comment)

Kendall B. Green DC70FEBB

Then SPJS should show that port of /dev/ttymxc3. What does SPJS show at launch?

My udoo sd card had problems. I will have to format and rebuild it before I
can run it
On Aug 3, 2015 11:54 AM, "John Lauer" notifications@github.com wrote:

Then SPJS should show that port of /dev/ttymxc3. What does SPJS show at
launch?


Reply to this email directly or view it on GitHub
#21 (comment)
.

The Serial Port window shows the following on start up of Chilipeppr:
Version" : "1.83"}
{"Commands" : ["list", "open [portName] [baud] [bufferAlgorithm
(optional)]", "send [portName] [cmd]", "sendnobuf [portName] [cmd]",
"sendjson {P:portName, Data:[{D:cmdStr, Id:idStr}]}", "close
[portName]", "bufferalgorithms", "baudrates", "restart", "exit",
"broadcast [anythingToRegurgitate]", "hostname", "version", "program
[portName] [core:architecture:name] [path/to/binOrHexFile]",
"programfromurl [portName] [core:architecture:name]
[urlToBinOrHexFile]"]}
{"Hostname" : "udoobuntu"}
list
It doesn't find any serial ports. When I open /dev/ttymxc3 115200, I
get the following:
open /dev/ttymxc3 115200
{"Cmd":"Open","Desc":"Got register/open on
port.","Port":"/dev/ttymxc3","IsPrimary":true,"Baud":115200,"BufferType":""}
list
{
"SerialPorts": [
{
"Name": "/dev/ttymxc3",
"Friendly": "/dev/ttymxc3",
"SerialNumber": "",
"DeviceClass": "",
"IsOpen": true,
"IsPrimary": true,
"RelatedNames": null,
"Baud": 115200,
"BufferAlgorithm": "",
"AvailableBufferAlgorithms": [
"default",
"tinyg",
"tinygg2",
"grbl",
"marlin"
],
"Ver": 1.83,
"UsbVid": "",
"UsbPid": ""
}

On 8/3/15, kendall.green@gmail.com kendall.green@gmail.com wrote:

My udoo sd card had problems. I will have to format and rebuild it before I
can run it
On Aug 3, 2015 11:54 AM, "John Lauer" notifications@github.com wrote:

Then SPJS should show that port of /dev/ttymxc3. What does SPJS show at
launch?


Reply to this email directly or view it on GitHub
#21 (comment)
.

Kendall B. Green DC70FEBB

well, opening it the way you did will work. you can go ahead and send data to it now. i think the reason it's filtering it out of the list is that it tries to look up the usb serial port meta data and something about that port is missing the filters built into spjs. that will have to get looked at, but in the meantime you can open the port manually like you're doing.

I have to send the following command before I can get the
serial-port-json-server to connect the UDOO Arduino to the Freescale
CPU:
stty -F /dev/ttymxc3 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost
-onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke
noflsh -ixon -crtscts
Should I include this command in the serial-port-json-server script in
/etc/init.d ?

On 8/3/15, John Lauer notifications@github.com wrote:

well, opening it the way you did will work. you can go ahead and send data
to it now. i think the reason it's filtering it out of the list is that it
tries to look up the usb serial port meta data and something about that port
is missing the filters built into spjs. that will have to get looked at, but
in the meantime you can open the port manually like you're doing.


Reply to this email directly or view it on GitHub:
#21 (comment)

Kendall B. Green DC70FEBB

Sounds good our go modify the code in spjs and send me a pull request

On Sun, Aug 9, 2015 at 9:31 AM -0700, "kendallgreen" <notifications@github.commailto:notifications@github.com> wrote:

I have to send the following command before I can get the
serial-port-json-server to connect the UDOO Arduino to the Freescale
CPU:
stty -F /dev/ttymxc3 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost
-onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke
noflsh -ixon -crtscts
Should I include this command in the serial-port-json-server script in
/etc/init.d ?

On 8/3/15, John Lauer notifications@github.com wrote:

well, opening it the way you did will work. you can go ahead and send data
to it now. i think the reason it's filtering it out of the list is that it
tries to look up the usb serial port meta data and something about that port
is missing the filters built into spjs. that will have to get looked at, but
in the meantime you can open the port manually like you're doing.


Reply to this email directly or view it on GitHub:
#21 (comment)

Kendall B. Green DC70FEBB

Reply to this email directly or view it on GitHubhttps://github.com//issues/21#issuecomment-129213515.

Not quite good to go. I still have to figure out exactly what I need
to do to get the serial port recognizable to serial-port-json-server.
Sometimes I get it to work, most of the time not. I will keep working
on it. I have ordered the gShield so when it arrives, I will begin
adding it to the UDOO.

On 8/9/15, John Lauer notifications@github.com wrote:

Sounds good our go modify the code in spjs and send me a pull request

On Sun, Aug 9, 2015 at 9:31 AM -0700, "kendallgreen"
<notifications@github.commailto:notifications@github.com> wrote:

I have to send the following command before I can get the
serial-port-json-server to connect the UDOO Arduino to the Freescale
CPU:
stty -F /dev/ttymxc3 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost
-onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke
noflsh -ixon -crtscts
Should I include this command in the serial-port-json-server script in
/etc/init.d ?

On 8/3/15, John Lauer notifications@github.com wrote:

well, opening it the way you did will work. you can go ahead and send
data
to it now. i think the reason it's filtering it out of the list is that
it
tries to look up the usb serial port meta data and something about that
port
is missing the filters built into spjs. that will have to get looked at,
but
in the meantime you can open the port manually like you're doing.


Reply to this email directly or view it on GitHub:
#21 (comment)

Kendall B. Green DC70FEBB

Reply to this email directly or view it on
GitHubhttps://github.com//issues/21#issuecomment-129213515.


Reply to this email directly or view it on GitHub:
#21 (comment)

Kendall B. Green DC70FEBB

I am going to copy the thread reply that I posted on the UDOO forums:

Resurrecting this thread for posterity's sake:
Using @kendallgreen's post above, and this thread there, I have been able to have TinyG2 (g2core) communicate with the Udoo through Chilipeppr.

First, I compiled the latest g2core, (fw 100), in Windows, using Atmel Studio using the instructions found on the g2core wiki. I used bossacto flash the code to the Due in UDOOBUNTU, after erasing and resetting it by using the jumper from J18 and throwing it onto J22 for one second, removing it, then putting onto J16 for a second, then removing it and placing it back onto J18.

With that out of the way, I recompiled the Linux Kernel, using make menuconfig all on the UDOO and after disabling the USB_Gadgetdriver and enabling the OTG_Support(which was already enabled, so I believe disabling the USB_Gadgetdriver fixed it), I copied it onto the SD Card.

After rebooting, I used the instructions in the thread mentioned above to set the two GPIOs:

# GPIO 128 = USB_OTG_SEL
echo 128 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio128/direction
echo 1 > /sys/class/gpio/gpio128/value
# GPIO 203 = VBUS_EN
echo 203 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio203/direction
echo 1 > /sys/class/gpio/gpio203/value

I have still yet to install the above into a script that will start upon boot.

I start the serial-port-JSON-server on the UDOO, and see that the TinyG2 is recognized through ttyACM0 and ttyACM1, not ttymxc3. On a PC, I start Chilipeppr, input the UDOO's IP address, and connect to the TinyG2.

After this, I can jog the motors and even run the sample gcode. There is an issue however, where, if the terminal is closed on the UDOO, the SAM3 has to be reset by removing the J18 and putting onto J16 for a second, putting it back onto J18, in order to reset it. After doing this, and restarting the device in the "Serial Port JSON Server" widget in Chilipeppr, I am able to continue using the controller.

I hope this helps someone.

  • Theo