I am using Virtual COM Port (VCP) example code from http://blog.memsme.com/stm32f4-virtual-com-port-2/ on STM32F4 Discovery Board to have USB VCP. This code is originally by ST and used by many other people in their projects
Communication with the STM32F4 over VCP works fine from Windows. In Linux (Ubuntu 12.04 x86), if I send data to the port with
echo "aasfg" > /dev/ttyACM0
then, the MCU gets the data and everything works fine. I can receive the continuous data stream with
cat /dev/ttyACM0
However, if I send data with the simple Python script that uses pySerial
import serial
sercom = serial.Serial('/dev/ttyACM0')
sercom.write('asdf')
then I stop receiving data with the cat command, and following cat commands also don't receive any data. The MCU is constantly executing some USB interrupt routines, never returning to execute actual application code. I can receive data from VCP again after re-plugging the device.
The STM32 USB VCP code is probably not perfect, but it is used by many other people in many projects so it should be good enough. I am not able to debug that code. I suspect that sending data with pySerial does something with the port that the VCP driver (either on STM32 or PC) does not like and I would like to track it down and hopefully still use pySerial.
I executed
stty --file=/dev/ttyACM0 -a
before and after pyserial broke the communication. After breaking the VCP with pyserial, setting -clocal became clocal and setting min = 1 became min = 0. Are these relevant in VCP communication and could they hint how to fix VCP with pySerial?
The serial port was actually fine. As I mentioned, the pySerial call changed the port parameters. The param min = 0 meant that cat /dev/ttyACM0 returned immediately, reconfiguring to min = 1 with stty made cat blocking and outputted the data as before.
Related
I am trying to get a simple Serial Port connection between dotnet 5 and a Marlin based printer board which is running some variant of a micro controller (LPC1768FBD100 https://www.arrow.com/en/products/lpc1768fbd100551/nxp-semiconductors).
I can open a connection to the board using other tools, send a "M503\n" command and receive a response, the tools I've used successfully are
Pronterface (Windows)
Arduino Serial Monitor (Windows)
miniterm (Linux)
putty (Windows)
So I know the board to be functioning correct in both Linux and Windows, but when attempting from .net, I am yet to succeed in getting any response back from the board. I have uploaded a simple tool in .net 5 that connects to a serial port and allows you to TX / RX strings,
https://github.com/devoctomy/SerialPortTester
I have tested this code in Windows and Linux, same port settings, no response back. I have also tested this exact code against a simple echo program running on an Arduino Uno board and it all works as expected, but for the life of me I can't get anything back from the other board.
I'm wondering if there's something about serial comms that these other apps are doing that I just don't know about. I'm using the same port settings which are shown in device manager across the board when testing in Windows, and also the same settings when testing in Linux.
In Linux the board comes up as ttyACM0, which is how my Arduino Uno is also mounted.
Any suggestions? I'm sure this isn't a "Marlin" issue, as only one of the other tools I've tested with is specific for Marlin and the Arduino serial monitor is about as basic as you can get. There's something I'm not doing in the .net code I think...
I've also tried someone elses old .net code and it also doesn't get a response back from this board, but does from my Arduino Uno running the echo program.
https://www.codeproject.com/Articles/23656/Termie-A-Simple-RS232-Terminal
Nick.
Edit:
I'm currently looking to see if it's just .net and the underlying mechanisms that is effected here and have found this page,
https://www.sparxeng.com/blog/software/must-use-net-system-io-ports-serialport
I've modified my tester code to access to base stream for sending / receiving data just in-case, but this has not fixed the issue.
Okay I got it, I knew I was missing something,
port.DtrEnable = true;
This fixes it and now I'm receiving and sending data to the Marlin board.
I am trying to upload this firmware sck_beta_v0_8_6 via Arduino 1.0.5-r2.
I have chosen LilyPad Arduino USB as the board. The device is a Smart Citizen Kit Urban Shield v.1.1.
The upload fails with the following error message:
Found programmer: Id = "BÛR"; type =
Software Version = . ; Hardware Version = .
avrdude: error: buffered memory access not supported. Maybe it isn't
a butterfly/AVR109 but a AVR910 device?
What am I doing wrong?
Sometimes, a different USB cable will make all the difference. There is a wide range in the quality of cables on the market, and sometimes, you get one on the ragged edge of acceptable.
The Arduino lilypad seems to be particularly susceptible to this. Glad this helped.
Press the Reset Button before upload the code, until you hear the "unplug" sound (in windows). Open the IDE and try it again
I had the same error message trying to upload a sketch to an Arduino Leonardo board from a Levovo laptop using Arduino ver 1.0.6. Both Device Manager and Arduino showed the board connected on COM3. Arduino also gave an error message that COM3 was being used by another App. I tried changing USB cables but got the same message. What worked was changing the USB outlet from the top right rear on the Lenovo to the bottom right rear outlet. It connected on COM8 and I was able to upload the sketch. Understand there are speed differences between the two outlets. Now all I need to do is figure out why I cannot upload sketches to the same Leonardo board on my HP laptop with Windows 10 and the most recent Arduino version. Connects on COM6 but hangs up when uploading. (Note: Also had to edit some Arduino library files that worked on ver 1.0.6 but showed compile errors in the latest version.)
I had the same error, but I later found that I had the wrong Arduino type selected, instead of Nano I had Yun.
I had the same issue when trying to upload code into Arduino Micro ( Chinese clone ). Spending hours on Google, flashing new bootloader - still nothing. Physical reset and opening COM port with boundrate 1200 doesn't work. Why?
I HAVE ATMEGA168 INSTEAD OF ATMEGA32u4!
Google is telling, that Arduino Micro got Atmega32u4, but my clone got Atmega168! First of all, check what atmega type do you have by lookup on black soldered chip on Arduino.
So instead of choose "Arduino Micro" on "Board" menu, i choose Arduino Nano and everything works!
I get this same error, avrdude: error: buffered memory access not supported also with garbage-looking output with programmer id # with versions ., when I point avrdude at the serial port of the stock main firmware of my Leonardo-compatible breakout board instead of the serial port offered during the bootloader; it seems that the latter is what avrdude can program?
The normal initial output when actually connecting to the bootloader would be something like:
Connecting to programmer: .
Found programmer: Id = "CATERIN"; type = S
Software Version = 1.0; No Hardware Version given.
To get to the bootloader you can either
press the reset button (if you don't have a reset button, connecting reset to ground), or
briefly connect to the main firmware's serial port at 1200 bps and disconnect
The bootloader will present a different serial USB device than the main firmware's serial USB device, so it may get assigned a different serial port number in your OS, usually the next available one. For instance in Windows my Leonardo-compatible main firmware was assigned COM3 and the bootloader was assigned COM4.
A python script, courtesy of https://nicholaskell.wordpress.com/tag/leonardo/, for doing this serial 'knock':
reset.py:
#!/usr/bin/env python
import serial, sys
serialPort = sys.argv[1]
ser = serial.Serial(
port=serialPort,
baudrate=1200,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS
)
ser.isOpen()
ser.close() # always close port
In Windows land, I have a cmd script for using this in a virtualenv
reset.cmd:
"C:\Program Files (x86)\Python37-32\Scripts\virtualenv.exe" pyreset_virtualenv
pyreset_virtualenv\Scripts\pip.exe install pyserial
pyreset_virtualenv\Scripts\python reset.py COM3
pause
adjust to suit your serial port and python path.
Either way, after getting the bootloader connected, you have a brief window of a couple of seconds where avrdude can connect to the new serial port to start programming before the bootloader will go into the main firmware again, at which point you'll have to do the reset again. So, once you figure out the bootloader serial port, you'll want to prepare the avrdude command line to run in advance, so you can launch it without delay after the reset.
While this answer isn't specific to the lilypad, you need to reset the board to write or read from/to the memory. However, If you are using avrdude in the terminal you must send a specific baudrate(1200 for the Leonardo) then close, wait 2 seconds, and open the port. At that point you can read and write to and from your Arduino. I achieved this using python.
Along the lines of:
Import serial
Import time
Import os
Seri=serial.Serial(yourConnectedPort, specificBaudRate)
Seria.close()
time.sleep(2)
Seri.open()
os.system(your avrdude command)
For the past week I have been programming an Arduino Uno with a computer running Windows 7. When I first started, I found the device on COM6 and was able to upload code no problem. Recently it suddenly stopped receiving code under the error:
Serial port 'COM6' not found. Did you select the right one from the
Tools > Serial Port menu?
The Serial port menu though is grayed out. Research has told me to open up Device Manager and update drivers but there is no other devices tab in my Device Manager. The Arduino is run off the power of the USB cable and runs the code I uploaded a few days ago just fine. What can I do to be able to upload code to the Arduino?
Update:
I installed the Arduino software on another computer and it does not recognize the Arduino either. One of the comments indicates that this could be a problem with the FTDI chip. How can I test if this is the case, and if it is, can I fix it?
There are two types of cable:
Charging Cable
Data Transfer Cable
So try changing the cable, if you have already tried every USB driver and port; or else
Install a new driver using this link, http://www.wch.cn/download/CH341SER_MAC_ZIP.html.
But after installing the driver, if it doesn't work, then change the cable.
For Linux:
To solve the problem, simply run the IDE as super user, so go to terminal and type 'sudo arduino'.
To solve this problem permanently:
In the terminal, run 'gksudo gedit'
In gedit, open the /usr/share/applications/arduino.desktop file.
Change the line Exec=arduino
to Exec=gksudo arduino. Save the file.
Similarly, do the same for Windows...
Also try to re-install Arduino driver.
The Arduino probably started using a different port. When you plug Arduinos into a different USB port it sometimes defaults to a new COM port. Check your device settings for which ports are being used and try each of those. Also try plugging it into a different USB port (if no ports are displayed) and it should register with a new COM. If that fails reboot your machine and repeat the above. If that fails reinstall the Arduino USB driver and repeat above. If that fails you might have fried your Arduino's USB chip (or some other hardware on the Arduino).
For Linux: Vinayk93 is completely right. Adjust the serial port's access rights like so:
$ cd /dev/ ; ls -l ttyA* -- find the right portname, then
$ sudo chmod 666 ttyACMx -- x is 0 or 1
I'm using Python 2.7, pySerial under windows 7.
I have 8 devices, they are connected to my PC via Virtual COM port (Silicon Labs CP210x USB to UART Bridge), I'm testing them With multiprocessing all 8 COM ports are open and each time i'm sending command to one unit only, there is no MultiThreading.
The problem is that after X time (it could be 10 minutes or 5 hours), the output Queue of the serial ports fails to send me responses. it's not a specific port each time it's a different port (it can be several ports)
It's importent to say, the device gets my command and do it. the fail is to get the response, The device i'm testing is OK for sure.
I am sniffing the port with Serial monitor, all the commands send OK and the device makes them, only it doesn't respond.
Any idea's ?
There could be n number of reasons:
Buffers might be full
Com Port is not working or might be
And finally the device is malfunctioning..
Check out these things might be it will help you.
I have a setup in which i use a USB serial adapter + some applicationwhich sends and receives data using that serial usb. But this setup which works on a Windows, or even in a VMWare Virtual windows, does not work under WINE. IT transmits data but i cannot receive data. The cable and the applications are same as in the working and non-working scenarios. I guess The fact that the application works over the USB serial cable just as fine under Virtual Windows(VMware running on linux) by mapping /dev/ttyUSB to the com port, no external software/DLL needed, means it does not need any specific driver. (Am i correct in this assumption that application doesnt need any driver?)
(I also tried with a different setup(different USB serial adapter + different application under WINE, but even that does not work under WINE, but it works fine under WIndows/Virtual Windows)
How can i get it working under WINE?
Any pointers appreciated.
Never tried wine with a serial port, but this could help:
cd .wine/dosdevices
ln -s /dev/ttyUSB0 com1