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
ARD-PARSE-BOARDS(1)					      General Commands Manual					       ARD-PARSE-BOARDS(1)

NAME
ard-parse-boards - Read data from the Arduino boards.txt file USAGE
Dump all the data in the file: $ ard-parse-boards --dump See which boards we know about: $ ard-parse-boards --boards Look for a particular board... $ ard-parse-boards --find uno multiple terms are implicitly ANDed: $ ard-parse-boards --find duemil 328 Dump all the data for a particular board: $ ard-parse-boards atmega328 Extract a particular field: $ ard-parse-boards atmega328 build.f_cpu DESCRIPTION
The Arduino software package ships with a boards.txt file which tells the Arduino IDE details about particular hardware. So when the user says he's got a shiny new Arduino Uno, boards.txt knows that it has a 16MHz ATmega328 on it. It would be nice to access these data from the command line too. In normal operation you simply specify the tag given to the board in the boards.txt file, and optionally a field name. This program then extracts the data to STDOUT. Most boards have names which are quite unwieldy, so we always refer to a board by a tag, not its name. Strictly the tag is the bit before the first dot in the boards.txt key. You can see a list of board tags and names with the "--boards" option. OPTIONS
--boards_txt=[file] Specify the full path to the boards.txt file. The following options all disable the normal 'lookup' operation. --dump Dump the complete database in YAML format. --boards Print a list of the tag and name of every board in the file. --find [query] <query> ... Find matching data. Strictly, return a list of values which match all of the query terms, treating each term as a case-insensitive regexp. For example: --find 328 List data containing 328 (anywhere in the value). --find due List data containing 'due' (e.g. duemilanove). --find 328 due List data containing both 328 and due. BUGS AND LIMITATIONS
There are no known bugs in this application. Please report problems to the author. Patches are welcome. AUTHOR
Martin Oldfield, ex-atelier@mjo.tc Thanks to Mark Sproul who suggested doing something like this to me ages ago. LICENSE AND COPYRIGHT
Copyright (c) 2011, Martin Oldfield. All rights reserved. This file is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. MAY 2012 ARD-PARSE-BOARDS(1)
All times are GMT -4. The time now is 10:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy