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
DROP FOREIGN DATA 
WRAPPER(7) SQL Commands DROP FOREIGN DATA WRAPPER(7) NAME
DROP FOREIGN DATA WRAPPER - remove a foreign-data wrapper SYNOPSIS
DROP FOREIGN DATA WRAPPER [ IF EXISTS ] name [ CASCADE | RESTRICT ] DESCRIPTION
DROP FOREIGN DATA WRAPPER removes an existing foreign-data wrapper. To execute this command, the current user must be the owner of the for- eign-data wrapper. PARAMETERS
IF EXISTS Do not throw an error if the foreign-data wrapper does not exist. A notice is issued in this case. name The name of an existing foreign-data wrapper. CASCADE Automatically drop objects that depend on the foreign-data wrapper (such as servers). RESTRICT Refuse to drop the foreign-data wrappers if any objects depend on it. This is the default. EXAMPLES
Drop the foreign-data wrapper dbi: DROP FOREIGN DATA WRAPPER dbi; COMPATIBILITY
DROP FOREIGN DATA WRAPPER conforms to ISO/IEC 9075-9 (SQL/MED). The IF EXISTS clause is a PostgreSQL extension. SEE ALSO
CREATE FOREIGN DATA WRAPPER [create_foreign_data_wrapper(7)], ALTER FOREIGN DATA WRAPPER [alter_foreign_data_wrapper(7)] SQL - Language Statements 2010-05-14 DROP FOREIGN DATA WRAPPER(7)
All times are GMT -4. The time now is 04:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy