Requirements for initiating a print on a 3D printer via USB - octoprint

I thought it would be fun to implement a rudimentary version of Octoprint that can receive a gcode file and initiate a print on my Prusa i3.
What are the requirements for initiating a print on a 3D printer via USB?

You can use the pySerial library in Python to send raw G-Code to the /dev/ttyWhereverYourPrinterIs serial device. Most printers specify their baud rate in their UI, or user's manual. My printer says its USB baud rate is 115200.

Quoting Gina Häußge:
If you are only targeting a very specific printer with a very specific firmware variant: serial connection and then read up on https://reprap.org/wiki/G-code. It becomes a horrible nightmare to implement and maintain though when you take the thousands of firmware variants out there into account, so beware.

Related

ALSA, TinyALSA support in Android Things for Raspberry Pi 0.5.1-devpreview

The 0.5.1-devpreview BSP for RPI3 comes with libtinyalsa.so, libalasautils.so but seemingly no adb shell commandline support for audio.
We are designing a custom audio board (with audio processor) for use with Android Things and Raspberry Pi and we would typically use ALSA utilities and custom kernel drivers for accessing this board under Raspian.
It is possible the default Android Things I2S peripheral drivers and Peripheral Manager support the stream interfaces we need (the same way the VoiceHat drivers were wrapped), but we have little to no information on the default drivers in the RPI3 BSP, and we don't have any information on how to override the default drivers in Android Things without a distro rebuild.
Seems silly to write a Native C++ low-level peripheral driver when so many audio processor companies already provide ALSA-ready ASoC drivers for device source tree use.
Best practices for writing your own audio driver for Android Things?
The VoiceHat driver is one example of how to do a userspace audio driver.
If you're using a custom audio board, you should be aware of the audio chip the board uses. Looking at that chip's datasheet, you should be able to use the same peripheral I/O (UART, GPIO, I2C, SPI) to configure the connection and read/write data over the I2S bus.
In the Google Assistant sample, the app registers the VoiceHat at the beginning of the activity and unregisters it at the end of the activity.

WiFi Beacon Packets

I'm trying to write a simple C code with WinPcap to broadcast a beacon packet and capture it in all nearby WiFi units. The code I'm using is very similar to the ones available at WinPcap[1].
The code runs fine if I create an ad-hoc network connection and join all the computers into it. However, this process of creating and joining to an ad-hoc network is cumbersome. It would be much better if, regardless of what network each computer is in, the beacon packets would be broadcasted and captured once the code is running.
As simple as this problem might sound, after some searching it seems that this is not possible to be done on windows (unless re-writing drivers or maybe the kernel):
Raw WiFi Packets with WinPcap[2]
Sending packets without network connection[3]
Does winpcap/libpcap allow me to send raw wireless packets?[4]
Basically, it would be necessary to use the WiFi in monitor mode, which is not supported in Windows[5]. Therefore, if the computers are not in the same network connection, the packets will be discarded.
1st Issue
I'm still intriguing, beacon and probe request packets are a normal traffic across the network. How they could be being sent and received constantly but the user is not allowed to write a program to do so? How to reconcile that?
2nd Issue
Does anyone has experience with Managed Wifi API[6]? I've heard that it might help.
3rd Issue
Acrylic WiFi[7] claims to have developed a NDIS driver which support monitor mode under Windows. Does anyone has experience with this software? Is it possible to integrate with C codes?
4th Issue
Is it possible to code such Wifi beacon on Linux? and on Android?
www.winpcap.org/docs/docs_412/html/main.html
stackoverflow.com/questions/34454592/raw-wifi-packets-with-winpcap/34461313?noredirect=1#comment56674673_34461313
stackoverflow.com/questions/25631060/sending-packets-without-network-connection-wireless-adapter
stackoverflow.com/questions/7946497/does-winpcap-libpcap-allow-me-to-send-raw-wireless-packets
en.wikipedia.org/wiki/Monitor_mode#Operating_system_support
managedwifi.codeplex.com/
www.acrylicwifi.com/
Couple questions I will try to answer. Mgmt and Ctrl packets are used for running a wifi network and don't contain data, I would not call these normal packets. Windows used to(I think still does) convert data packets into ethernet frames and pass it up the stack. Beacon and Probe Req pkts are not necessary for TCP/IP stack to work, ie. web browsers don't need beacon frames to get your web page. Most OS's need minimal info from mgmt/ctrl pkts to help a user interact with a wifi adapter, most mgmt/ctrl pkts only are useful to the driver(and low level os components) to figure how to interact with the network. This way the wifi adapters look and act like ethernet adapters to high level os components.
Never had any experience with Managed Wifi API or Acrylic, so can't give you any feedback.
Most analyzers that capture and send packets do it in 2-3 separate modes mainly because of hardware. Wifi adapters can be in listen mode(promiscuous mode and/or monitor mode) or adapter mode. To capture network traffic you need to listen and not send, ie. if someone sends a pkt while you are sending you miss that traffic. In order to capture(or send) traffic you will need a custom NDIS driver in windows, on linux many of them already do. Checkout wireshark or tshark, they use winpcap to capture pkts in windows and there are some adapters they recommend to use to capture pkts.
Yes it is possible to send a beacon on linux, ie. Aireplay. I know its possible to capture traffic on Android but you it needs to have rooted or custom firmware, which I would believe also means you can send custom pkts. If you are simply trying to send a pkt it might be easier to capture some traffic in tshark or wireshark and use something like aireplay to resend that traffic. You could also edit the packet with a hex editor to tune it to what you need.

Ability to monitor filter beacon data in wireshark using MAC address

What would be the filter command in wireshark to find the specific MAC address of the beacon ?
So for the MAC address of F4:8B:F9:B0:61 how would I filter out this specific beacon in wireshark?
Error after following tutorial by davidyoung :
"Error in column 'payload protocol' dissector not found"
If you want to use Wireshark with Ubertooth, you must either build or buy the Ubertooth board: http://ubertooth.sourceforge.net/
I have not done this, so I can not speak to the exact steps or the relative merits of this approach. The approach I have taken to sniffing Bluetooth LE traffic is to buy a TI CC2540 USB dongle, which you can get with sniffing software for Windows: http://processors.wiki.ti.com/index.php/BLE_sniffer_guide
An alternative to the Ubertooth that #davidgyoung mentioned is the Adafruit Bluefruit LE Sniffer. At $30 it is significantly cheaper than the Ubertooth.
Assuming you already have a hcidump or know how to create one.
try following as filter:
frame[7:6] == F4:8B:F9:B0:61
In Version 1.10.6 it seems to give me only the packages from that specific beacon.
It's possible to even create a dissector for the advertising data, if you know how to decode it.

Need help using Arduino R3 as serial-to-usb converter (to program something)

I have researched (and learnt quite a bit), but I have little experience in programming and only really understand basic sketches so far. I would like to use the Arduino R3 (more specifically, the usb to serial converter chip) to program a full-size hobby radio.
I have connected my radio to the Arduino appropriately (5V, Rx, Tx, Gnd) and put the Arduino into Tristate mode (apparently you have to do this..), but I seem to be lacking appropriate drivers. I basically want my Arduino R3 to function exactly like this: CP2102 . Please note that I am not being super cheap. To get something like that where I live would take at the very least a month. Some people also say that I should remove the Atmega chip. The ultimate goal is that I have a device, with drivers, on a com port and not just an "unknown device".
So, my questions are: leave the Atmega on, or remove it? and which drivers do I need?
Thanks!
EDIT: I found almost exactly what I need just after I posted. For some reason I couldn't get it to work, but maybe you could help me understand? Here's the link LINK If anyone is keen to help me out!
Just to make it clear: it has been done before, but I get the feeling people leave out things which they think are obvious, but to the not-yet-professional tinkerer like me aren't :/
Thanks so much!
It seems like the links you reference are for older Arduinos with an FTDI chip. The Arduino Uno doesn't use that. Here's a link for using the Uno
So! All of the older Arduinos (NG, Diecimila and Duemilanove) have
used an FTDI chip (the FT232RL) to convert the TTL serial from the
Arduino chip (Atmel ATmega). This allows for printable debugging,
connecting to software like PureData/Max, Processing, Python, etc.
etc. It also allows updating the firmware via the serial bootloader.
The good news about the FT232RL has royalty-free drivers and pretty
much just works. The bad news is that it can -only- act as a
USB/Serial port. It can't act like a keyboard, mouse, disk drive, MIDI
device, etc.
and
The Arduino Uno has a number of facilities for communicating with a
computer, another Arduino, or other microcontrollers. The ATmega328
provides UART TTL (5V) serial communication, which is available on
digital pins 0 (RX) and 1 (TX). An ATmega16U2 on the board channels
this serial communication over USB and appears as a virtual com port
to software on the computer. The '16U2 firmware uses the standard USB
COM drivers, and no external driver is needed. However, on Windows, a
.inf file is required. The Arduino software includes a serial monitor
which allows simple textual data to be sent to and from the Arduino
board. The RX and TX LEDs on the board will flash when data is being
transmitted via the USB-to-serial chip and USB connection to the
computer (but not for serial communication on pins 0 and 1).
Basically the LINK you provided, shows the user HACKING the Arduino. Using the USB/Serial(TTL) converter(what ever chip that is on your Arduino) to link to the Radio's Mini Din connector, in place of connecting to the Arduino's CPU.
As stated in other answer the Arduino uses a CHIP (of some flavor) to bridge the USB(Virtual Serial Port) to the Serial Port of the ATmega328 micro. These pins are available on the Shields connector 0(RX) and 1(TX). Hence you see the picture wiring those pins to the Radio's DIN connector.
Where I would expect in addition the RESET of the Arduino's CPU would be held to GND, this would force the pins into Hi. Simply with an extra wire jump the RESET pin to a GND.
It's working! Somewhere along the line the drivers for my arduino seem to have been deleted, so I reinstalled them, did what you said, and learnt something.
So to clarify for others: pretty much plug and play (as the link I posted suggests), but make sure to install the arduino drivers properly.
Thanks a lot for the help!

Writing Device Drivers for a Microcontroller(any)

I am very enthusiastic in writing device drivers for a microcontroller(like PIC, Atmel etc).
Since I am a newbie in this controller-coding-area I just want to know whether writing device drivers for controller is same as we write for linux( or any other OS) ?
Also can anyone suggest some online device driver building tutorial for the same ..?
Thanks,
If you are thinking about developing the device drivers to interface your device with a host computer (probably using USB), then most of the microcontrollers nowadays implement default classes that rely on native drivers.
A concrete example:
If you use a PIC18F4555, you can use the regular HID (human interface device) windows driver to communicate with your microcontroller (given you implemented it correctly). No need to develop any driver.
Writing a device driver for an MCU is a pretty far cry from writing it for a OS. Most MCUs won't have an OS running on them at all. You'll generally end up writing some low level Interrupt Service Routines (ISRs) and filling up buffers, that your application software will end up emptying. You don't have to fit into any device driver paradigm that an O/S has defined. You basically have to read the datasheet for the device you are wanting to interface with and read and write to its memory over whatever interface it might use (e.g. SPI, I2C, UART, etc.). Ultimately the device driver ought to provide intuitive function calls to the application software.
If you are using AVR MCU like atmega then you can use vusb (https://www.obdev.at/products/vusb/index.html) for those MCU that don't have any HID and handles the interrupts by connecting D+ and D- pins of the USB to digital I/O ports of the MCU.
The atmegaU2 packages have their own USB communication ports and HID.

Resources