Sponsored Content
Top Forums UNIX for Advanced & Expert Users Another binary manipulation thread. Post 302849029 by wisecracker on Friday 30th of August 2013 04:57:05 PM
Old 08-30-2013
Getting byte zero, in pseudo_zero mode, into the shell is easy as the Arduino Voltmeter DEMO below shows.

However I have attempted to put byte zero into a string variable as a single character and I now concede defeat. It is not possible with default commands to force value of byte zero into any variable, so a minimum of "\0", 2 bytes, is required to _emulate_ it...

Code:
#!/bin/bash --posix
# $VER: Arduino.sh_Version_0.00.10_(C)2013_B.Walker_G0LCU.

Arduino_Device="Unknown!"
DATA="0"

> /tmp/usbdata.raw

echo "Remove the Arduino board from the USB port ,IF, it is connected."
read -p "Press <CR> to continue:- " -e Arduino_Device
echo "The error report IS expected!"
ls /dev/cu.usb*
echo "Now connect the Arduino board to the USB port."
sleep 5
read -p "Press <CR> to continue:- " -e Arduino_Device

Arduino_Device="`ls /dev/cu.usb*`"
clear
while true
do
	if [ ${#DATA} -le 0 ]
	then
		echo "ERROR! Unsuccessful data aquisition..."
		break
	fi
	DATA=$[ ( $DATA * 20 ) ]
	printf "\\x1B[11;33f0.000 Volts DC.\n\n"
	if [ ${#DATA} -eq 2 ]
	then
		printf "\\x1B[11;36f$DATA\n\n"
	fi
	if [ ${#DATA} -eq 3 ]
	then
		printf "\\x1B[11;35f$DATA\n\n"
	fi
	if [ ${#DATA} -eq 4 ]
	then
		DATA="${DATA:0:1}.${DATA:1:2}"
		printf "\\x1B[11;33f$DATA\n\n"
	fi
	dd if="$Arduino_Device" of=/tmp/usbdata.raw bs=1 count=1
	DATA=`hexdump -n1 -s0 -v -e '1/1 "%u"' /tmp/usbdata.raw`
done

Display like this:-
Code:
Last login: Fri Aug 30 21:34:09 on ttys000
AMIGA:barrywalker~> ./Arduino.sh
Remove the Arduino board from the USB port ,IF, it is connected.
Press <CR> to continue:- 
The error report IS expected!
ls: /dev/cu.usb*: No such file or directory
Now connect the Arduino board to the USB port.
Press <CR> to continue:- 

                                0.000 Volts DC.

1+0 records in
1+0 records out
1 bytes transferred in 0.007705 secs (130 bytes/sec)c)

# AND...

                                2.580 Volts DC.

1+0 records in
1+0 records out
1 bytes transferred in 0.007620 secs (131 bytes/sec)))

# AND...

                                5.100 Volts DC.

1+0 records in
1+0 records out
1 bytes transferred in 0.007678 secs (130 bytes/sec)))

 

4 More Discussions You Might Find Interesting

1. Programming

How to cancel a thread safely from the initial thread?

how about asynchronous canceling? or with signal? if with signal whether it effects the process? my english so badly :( :( (1 Reply)
Discussion started by: alan.zhao
1 Replies

2. Shell Programming and Scripting

Convert binary file to csv and then back to the binary format

Hello *nix specialists, Im working for a non profit organisation in Germany to transport DSL over WLAN to people in areas without no DSL. We are using Linksys WRT 54 router with DD-WRT firmware There are at the moment over 180 router running but we have to change some settings next time. So my... (7 Replies)
Discussion started by: digidax
7 Replies

3. Shell Programming and Scripting

Another Building Block, Binary File Manipulation...

Apologies for any typos, and IF this has been done before... This is yet another building block. The code generates a 256 byte binary file of _characters_ 0x00 to 0xFF for general usage and generates another binary file manipulated in a basic way. I need this facility for a kids project I am... (0 Replies)
Discussion started by: wisecracker
0 Replies

4. Forum Support Area for Unregistered Users & Account Problems

Not able to post thread/reply to thread

Dear Moderator I am not able to post any new thread or post reply to mine old thread. Kindly help as i am stuck on one problem and needed suggestion. Regards Jaydeep (1 Reply)
Discussion started by: jaydeep_sadaria
1 Replies
UPLCOM(4)						   BSD Kernel Interfaces Manual 						 UPLCOM(4)

NAME
uplcom -- USB support for Prolific PL-2303/2303X/2303HX serial adapters driver SYNOPSIS
To compile this driver into the kernel, place the following lines in your kernel configuration file: device uplcom device ucom Alternatively, to load the driver as a module at boot time, place the following line in loader.conf(5): uplcom_load="YES" DESCRIPTION
The uplcom driver provides support for various serial adapters based on the Prolific PL-2303, PL-2303X and PL-2303HX USB-to-RS232 Bridge chips. The device is accessed through the ucom(4) driver which makes it behave like a tty(4). HARDWARE
The uplcom driver supports the following adapters: o ATEN UC-232A o BAFO BF-800 o BAFO BF-810 o Belkin F5U257 o ELECOM UC-SGT o HAL Corporation Crossam2+USB IR commander o Hama USB RS-232 Serial Adapter o Hamlet exagerate XURS232 o IOGEAR UC-232A o I/O DATA USB-RSAQ o I/O DATA USB-RSAQ2 o I/O DATA USB-RSAQ3 o Mobile Action MA-620 Infrared Adapter o PLANEX USB-RS232 URS-03 o RATOC REX-USB60 o Radio Shack USB Serial Cable o Sandberg USB to Serial Link (model number 133-08) o SOURCENEXT KeikaiDenwa 8 (with and without charger) o Sony Ericsson USB Cable (Susteen USB Data Cable) o Willcom W-SIM DD PHS terminal.(WS002IN) SEE ALSO
tty(4), ucom(4), usb(4) HISTORY
The uplcom driver appeared in NetBSD 1.6. This manual page was adopted from NetBSD by Tom Rhodes <trhodes@FreeBSD.org> in April 2002. BSD
November 22, 2006 BSD
All times are GMT -4. The time now is 01:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy