Viewing values in hyper terminal
Hello all,
I am quite new to WSN programming. I have Crossbow and required hardware( micaz motes, mib510 programming board and a serial port cable). Can I view a Hello Message send by mote in the hyper terminal. Please guide me from the very beginning. Since I am purely from a computer science background . Thanks in advance
Rekha
sas-Qatar wrote:
Sorry Didn't figure out how that could be done...
To start a new thread just click on the New Message button.
anyhow...I am attaching the manual for my GPR, as well the error code.
I want to input XON as a command to make sure my GPR will be booting, I did that through hyper terminal and it worked fine, but through lab veiw not sure why it is not working.
That error code indicates you are trying to use events, but have not actually registered for an event. Why are you using the Basic 2 Port example? You should be using the regular Basic Serial Write and Read example. The manual indicates that you need to append a carriage return to the commands. In the Basic Serial Write and Read example you can do so by replacing the "\n" with "\r". Thus, the control should look like this:
Attachments:
new message.PNG 15 KB
Basic Serial Write and Read_FP.png 4 KB
Similar Messages
-
AT Commands , Hyper Terminal and java
Hi,
I have following problem, i have PCMCIA Type -11 Wireless modem.its installed on my system COM4 port.
Now first problem is that when i try to connect with hyper terminal to COM4 there is no response from it .It become Idle.but when i connect with COM3 which is my Dialup modem port it works fine with all AT commands.
Now 2nd things is that same with below code i tried to send sms using AT command on COM4 its has same behaviour as it was in Hyper terminal mean no response. no Data Available event occour
Please help me in this regard and suggest me a solution.
package serialio;
import javax.comm.*;
import java.io.*;
import java.util.*;
public class SimpleWrite
implements Runnable, SerialPortEventListener
public void run()
static Enumeration portList;
static CommPortIdentifier portId;
static String dest = "0517111930";
static String messageString = "Hello";
InputStream inputStream;
static SerialPort serialPort;
static OutputStream outputStream;
public void serialEvent(SerialPortEvent event)
switch (event.getEventType())
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
break;
case SerialPortEvent.DATA_AVAILABLE:
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
String line = "";
try
while ( (line = reader.readLine()) != null)
System.out.println(line);
catch (IOException e)
System.err.println("Error while reading Port " + e);
break;
} //switch
public SimpleWrite(SerialPort serial)
try
inputStream = serial.getInputStream();
try
serial.addEventListener(this);
catch (TooManyListenersException e)
System.out.println("Exception in Adding Listener" + e);
serial.notifyOnDataAvailable(true);
catch (Exception ex)
System.out.println("Exception in getting InputStream" + ex);
public static void main(String[] args)
// String line1="AT+CMGF=1\r\n";
// String line2="AT+CMGS=\""+ dest+"\"\r\n";
// String line3=messageString+"\r\n";
// String line4="\u001A";
String line1 = "AT+CMGF=1\r\n";
String line2 = "AT+CMGS=" + dest + "\r\n";
String line3 = messageString + "^Z\r\n";
// String line4 = "\u001A";
portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements())
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL)
System.out.println("SMS Sending........");
if ( portId.getName().equals("COM4"))
System.out.println("SMS Sending....Port Found");
try
serialPort = (SerialPort) portId.open("SimpleWriteApp", 2000);
SimpleWrite wr = new SimpleWrite(serialPort);
catch (PortInUseException e)
System.out.println("Port In Use " + e);
try
outputStream = serialPort.getOutputStream();
catch (IOException e)
System.out.println("Error writing to output stream " + e);
try
serialPort.setSerialPortParams(
2400,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
catch (UnsupportedCommOperationException e)
try
outputStream.write(line1.getBytes());
outputStream.write(line2.getBytes());
outputStream.write(line3.getBytes());
outputStream.flush();
catch (IOException e)
System.out.println("Error writing message " + e);
/** show text in the text window
* @param Text text string to show on the display
public static void showText(String Text)
System.out.println(Text);
}* SerialWrite.java
* Created on September 10, 2008, 2:51 PM
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
package com.sms;
import javax.comm.*;
import java.io.*;
import java.util.*;
public class SerialWrite implements Runnable, SerialPortEventListener
static String output="";
public void run()
static Enumeration portList;
static CommPortIdentifier portId;
static String dest = "+91999999999";
static String messageString = "Hello Testing11";
InputStream inputStream;
static SerialPort serialPort;
static OutputStream outputStream;
public void serialEvent(SerialPortEvent event)
switch (event.getEventType())
case SerialPortEvent.BI:
case SerialPortEvent.OE:
case SerialPortEvent.FE:
case SerialPortEvent.PE:
case SerialPortEvent.CD:
case SerialPortEvent.CTS:
case SerialPortEvent.DSR:
case SerialPortEvent.RI:
case SerialPortEvent.OUTPUT_BUFFER_EMPTY:
System.out.println("Error");
break;
case SerialPortEvent.DATA_AVAILABLE:
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
String line = "";
try
while ( (line = reader.readLine()) != null)
if(line.equalsIgnoreCase("OK") || (line.indexOf("+CMGS") != -1))
output=line;
Thread.sleep(10);
catch (Exception e)
System.err.println("Error while reading Port " + e);
break;
} //switch
public SerialWrite(SerialPort serial)
try
inputStream = serial.getInputStream();
try
serial.addEventListener(this);
catch (TooManyListenersException e)
System.out.println("Exception in Adding Listener" + e);
serial.notifyOnDataAvailable(true);
catch (Exception ex)
System.out.println("Exception in getting InputStream" + ex);
public static void main(String[] args) throws Exception
int i=0;
String line0 = "ATZ\r\n";
String line1 = "AT+CMGF=1\r\n";
String line2 = "AT+CSCA=\"+919888888\"\r\n";
//String line3 = "AT+CMGS="+"\""+ dest + "\""+"\r\n";
String line3 = "AT+CMGS="+"\""+ args[0] + "\""+"\r\n";
//String line4 = messageString;
String line4 = args[1];
portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements())
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL)
System.out.println("SMS Sending........");
if ( portId.getName().equals("/dev/ttyACM0"))
System.out.println("SMS Sending....Port Found");
try
serialPort = (SerialPort) portId.open("SerialTestApp", 2000);
SerialWrite wr = new SerialWrite(serialPort);
catch (PortInUseException e)
System.out.println("Port In Use " + e);
try
outputStream = serialPort.getOutputStream();
catch (IOException e)
System.out.println("Error writing to output stream " + e);
try
serialPort.setSerialPortParams(
115200,
SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
catch (UnsupportedCommOperationException e)
try
outputStream.write(line0.getBytes());
Thread.sleep(10);
while(!output.equalsIgnoreCase("ok"))
Thread.sleep(10);
output="";
outputStream.write(line1.getBytes());
while(!output.equalsIgnoreCase("ok"))
Thread.sleep(10);
output="";
outputStream.write(line2.getBytes());
while(!output.equalsIgnoreCase("ok"))
Thread.sleep(10);
output="";
for(i=0;i<3;i++)
outputStream.write(line3.getBytes());
Thread.sleep(10);
outputStream.write(line4.getBytes());
Thread.sleep(10);
outputStream.write(26);
outputStream.write("\r\n".getBytes());
outputStream.flush();
while(!output.equalsIgnoreCase("ok"))
Thread.sleep(10);
output="";
System.out.println("Message Sent !!!!!!!!!1");
catch (IOException e)
System.out.println("Error writing message " + e);
/** show text in the text window
* @param Text text string to show on the display
public static void showText(String Text)
System.out.println("TEXT "+Text);
} -
List manager displaying view value and not return value
Hello,
I'm using a list manager based on pop-up LOV. When I click on an item on the pop-up window, the window is closed and the return value is inserted in the page textbox. I would like to have (as expected) the view value, and have the return value used just as field value during form submit.
I'm using Application Express 2.1.0.00.39
Thanks.
EugenioUnfortunately, you can't. The way to do it is to return the display value into the List Manger item and then use the APEX_UTIL.STRING_TO_TABLE function to loop through the values and fetch the IDs. You will need to make sure the LOV items are unique and don't contain any colons.
I hope that helps
Shunt -
Install solaris via hyper terminal
Hi,
I just got my new ultra 5 box and I was wondering what type of cable and hyper terminal settings I need in order to get this thing rolling.
The type of cable I used before was a null modem cable db9F --> db9F. Then I read I needed db9 --> db25. So I went out and look for db9 --> db25 only to find that there wasn't any male to male cables ... any suggestions would be great!
Thanks,
IPv6Dear friends,
I have the same problem...
I have a VGA adapter in my sparc 5, but my 14" monitor doesn't show nothing (only a new MAG 17" but it's not mine).
So, I switched to HyperTerminal.
I made more than 10 Null modem cables, with all the options, but I could not see nothing and I cannot install my mchine.
The explanation of the cable here, I didn't understand so good, albeit that, I make the cable but it didn't work.
Does anybody knows what to do, step by step, or where can I read it?
Thank you very much!
Ilan. -
How to install Solaris 9 connected via Hyper Terminal
Hi All ,
We have planned to Install Solaris 9 in E250. We have connected the console throgh Hyper Terminal.
We are not able to see the options clearly in the console. The options are not in clear way. It is very difficult to install.
Please advice how to install Solaris 9 in Text mode and terminal type for installing the solaris 9 via Hyper Terminal.
I am awaiting for your reply.
Regards,
R. Rajesh Kannan.When the install starts, select a terminal type of VT100
The screens should display correctly then. -
V490 is not loging using hyper terminal after modifying hosts file
Dear ALL,
I am new user of Solaris 10. My Director has given me task to configure Sun fire V490 server. Today I was configuring the Network of the server using vi editor , I had change the ip from /etc/inet/hosts file after modifying the file I had restarted the system but it was not loging into root user. it gives an error "unable to login" , I searched the problem and find out that I missd the netmask file to modify but now I am unable to loging through hyper terminal . I am configuring the server using hyper terminal , is there other way to configure the server , because there is no vga card for the monitor display. How can I modify my server files. Please help me in this regard . I shall remain thankful to you.With Lions should be fine editing the standard /etc/hosts file
# Host Database
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
127.0.0.1 localhost
add here your IPv4 hosts list
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost -
RGB values of current terminal color settings?
The colors displayed for different ANSI escape codes are configurable via .Xdefaults or directly on the command line via other ANSI escapes.
Is there any way to dump the current values from a terminal? For example, given the ANSI escape code "\033[31m", I would like to know the current RGB values used to display it.
Obviously this will depend on the terminal (e.g. urxvt can have different settings from xterm), but I'm hoping that there is some obscure tool to do this.Coincidentally, I recently wrote a script to do exactly this: query all the color values from a terminal emulator and show them in a nice table. I was planning to make a thread for this, but this thread is perfect. In my opinion, the strategy of querying colors from the terminal itself is superior (when it is supported by the terminal) to mucking around with .Xresources, .Xdefaults, or "xrdb --query", which only work in pretty limited situations. The drawbacks of my approach are: (1) it can be challenging to make the same code work on different terminal emulators, and (2) you have to use it from the terminal you want to query, and not from within a screen or tmux session. (I think there may be partial workarounds for (2), but I haven't implemented them.) I've tested my code on a number of terminals, and the upshot is that xterm and urxvt are supported flawlessly, and VTE-based terminals like gnome-terminal and XFCE's "Terminal" are almost fully supported. (I wasn't able to query the default foreground and background colors, but everything else seems to work.) Most other X terminals don't seem to support this method of querying color values.
Here's an example of what the script produces:
Obviously, that's a heavily formatted table, but I think the code has enough comments that you can take what you need from it. It works under python 3 or python 2.7.
Edit: This version is superseded by the one in post #27, which is structured better. I'm leaving this here since some of the future replies refer to it.
#!/usr/bin/python
This is a Python script to show off your terminal ANSI colors (or more
colors, if your terminal has them). It works on both Python 2.7 and
Python 3.
This script must be run from the terminal whose colors you want to
showcase. Not all terminal types are supported (see below). At the
very minimum, 16-color support is required.
Fully supported terminals:
xterm
urxvt
For these terminals, this script can show a color table with correct RGB
values for each color. It queries the RGB values from the terminal
itself, so it works even if you change the colors after starting the
terminal.
Mostly supported terminals: pretty much all VTE-based terminals. This
includes:
vte
Terminal (XFCE)
gnome-terminal
terminator
tilda
and many more. These are on "mostly" status because I don't know how to
query their foreground and background colors. Everything else works,
though, albeit with noticeable slowness (which may be beyond this
script's control).
Somewhat supported terminals: pretty much all other X-client terminals
I've tried. These include:
konsole (KDE)
terminology (Enlightenment)
Eterm (Enlightenment)
(etc.)
For these terminals, the script can output a color table just fine, but
without RGB values.
Unsupported terminals:
ajaxterm
Linux virtual console (i.e., basic TTY without X-windows)
Warning: do not run this script on the Linux virtual console unless you
want a garbled TTY! That said, you can still type `tput reset<Enter>'
afterward to get back to a usable console. :-) The situation with
ajaxterm is similar, but not as bad.
If a terminal isn't mentioned here, I probably haven't tried it. Attempt
at your own risk!
Note regarding screen/tmux: this script can theoretically be run from a
screen or tmux session, but you will not get any RGB values in the
output (indeed, a screen session can be opened on multiple terminals
simultaneously, so there typically isn't a well defined color value for
a given index). However, it's interesting to observe that screen and
tmux emulate a 256 color terminal independently of the terminal(s)
to which they are attached, which is very apparent if you run the script
with 256-color output on a screen session attached to a terminal with 8-
or 16-color terminfo (or with $TERM set to such).
This code is licensed under the terms of the GNU General Public License:
http://www.gnu.org/licenses/gpl-3.0.html
and with absolutely no warranty. All use is strictly at your own risk.
from sys import stdin, stdout, stderr
import re
import select
import termios
from collections import defaultdict
from argparse import (ArgumentParser, ArgumentError)
# Operating system command
osc = "\033]"
# String terminator
# ("\033\\" is another option, but "\007" seems to be understood by
# more terminals. Terminology, for example, doesn't seem to like
# "\033\\".)
st = "\007"
# Control sequence introducer
csi = "\033["
# ANSI SGR0
reset = csi + 'm'
# Errors that may be raised by rgb_query
num_errors = 0
class InvalidResponseError(Exception):
The terminal's response couldn't be parsed.
def __init__(self, q, r):
global num_errors
num_errors += 1
Exception.__init__(self, "Couldn't parse response " + repr(r) +
" to query " + repr(q))
class NoResponseError(Exception):
The terminal didn't respond, or we were too impatient.
def __init__(self, q):
global num_errors
num_errors += 1
Exception.__init__(self, "Timeout on query " + repr(q))
# Wrappers for xterm & urxvt operating system controls.
# These codes are all common to xterm and urxvt. Their responses aren't
# always in the same format (xterm generally being more consistent), but
# the regular expression used to parse the responses is general enough
# to work for both.
# Note: none of these functions is remotely thread-safe.
def get_fg(timeout):
Get the terminal's foreground (text) color as a 6-digit
hexadecimal string.
return rgb_query([10], timeout)
def get_bg(timeout):
Get the terminal's background color as a 6-digit hexadecimal
string.
return rgb_query([11], timeout)
def get_color(a, timeout):
Get color a as a 6-digit hexadecimal string.
return rgb_query([4, a], timeout)
def test_fg(timeout):
Return True if the terminal responds to the "get foreground" query
within the time limit and False otherwise.
return test_rgb_query([10], timeout)
def test_bg(timeout):
Return True if the terminal responds to the "get background" query
within the time limit and False otherwise.
return test_rgb_query([11], timeout)
def test_color(timeout):
Return True if the terminal responds to the "get color 0" query
within the time limit and False otherwise.
return test_rgb_query([4, 0], timeout)
def test_rgb_query(q, timeout):
Determine if the terminal supports query q.
Arguments: `q' and `timeout' have the same interpretation as in
rgb_query().
Return: True if the terminal gives a valid response within the
time limit and False otherwise.
This function will not raise InvalidResponseError or
NoResponseError, but any other errors raised by rgb_query will
be propagated.
try:
rgb_query(q, timeout)
return True
except (InvalidResponseError, NoResponseError):
return False
# String to use for color values that couldn't be determined
rgb_placeholder = '??????'
# This is what we expect the terminal's response to a query for a color
# to look like. If we didn't care about urxvt, we could get away with a
# simpler implementation here, since xterm and vte seem to give pretty
# consistent and systematic responses. But I actually use urxvt most of
# the time, so....
ndec = "[0-9]+"
nhex = "[0-9a-fA-F]+"
crgb = ("\033\\]({ndec};)+rgba?:" +
"({nhex})/({nhex})/({nhex})(/({nhex}))?").format(**vars())
re_response = re.compile(crgb)
# The problem I'm attempting to work around with this complicated
# implementation is that if you supply a terminal with a query that it
# does not recognize or does not have a good response to, it will simply
# not respond *at all* rather than signaling the error in any way.
# Moreover, there is a large variation in how long terminals take to
# respond to valid queries, so it's difficult to know whether the
# terminal has decided not to respond at all or it needs more time.
# This is why rgb_query has a user-settable timeout.
P = select.poll()
P.register(stdin.fileno(), select.POLLIN)
def flush_input():
Discard any input that can be read at this moment.
repeat = True
while repeat:
evs = P.poll(0)
if len(evs) > 0:
stdin.read()
repeat = True
else:
repeat = False
def rgb_query(q, timeout=-1):
Query a color-valued terminal parameter.
Arguments:
q: The query code as a sequence of nonnegative integers, i.e.,
[q0, q1, ...] if the escape sequence in pseudo-Python is
"\033]{q0};{q1};...;?\007"
timeout: how long to wait for a response. (negative means
wait indefinitely if necessary)
Return: the color value as a 6-digit hexadecimal string.
Errors:
NoResponseError will be raised if the query times out.
InvalidResponseError will be raised if the terminal's
response can't be parsed.
See
http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
("Operating System Controls") to see the various queries
supported by xterm. Urxvt supports some, but not all, of them,
and has a number of its own (see man -s7 urxvt).
Warning: before calling this function, make sure the terminal is
in noncanonical, non-blocking mode.
query = osc + ';'.join([str(k) for k in q]) + ';?' + st
flush_input()
stdout.write(query)
stdout.flush()
# This is addmittedly flawed, since it assumes the entire response
# will appear in one shot. It seems to work in practice, though.
evs = P.poll(timeout)
if len(evs) == 0:
raise NoResponseError(query)
r = stdin.read()
m = re_response.search(r)
if not m:
raise InvalidResponseError(query, r)
# (possibly overkill, since I've never seen anything but 4-digit RGB
# components in responses from terminals, in which case `nd' is 4
# and `u' is 0xffff, and the following can be simplified as well
# (and parse_component can be eliminated))
nd = len(m.group(2))
u = int('f'*nd, 16)
# An "rgba"-type reply (for urxvt) is apparently actually
# rgba:{alpha}/{alpha * red}/{alpha * green}/{alpha * blue}
# I opt to extract the actual RGB values by eliminating alpha. (In
# other words, the alpha value is discarded completely in the
# reported color value, which is a compromise I make in order to get
# an intuitive and compact output.)
if m.group(5):
# There is an alpha component
alpha = float(int(m.group(2), 16))/u
idx = [3, 4, 6]
else:
# There is no alpha component
alpha = 1.0
idx = [2, 3, 4]
c_fmt = '%0' + ('%d' % nd) + 'x'
components = [int(m.group(i), 16) for i in idx]
t = tuple(parse_component(c_fmt % (c/alpha)) for c in components)
return "%02X%02X%02X" % t
def parse_component(s):
Take a string representation of a hexadecimal integer and transorm
the two most significant digits into an actual integer (or double
the string if it has only one character).
n = len(s)
if n == 1:
s += s
elif n > 2:
s = s[:2]
return int(s, 16)
def test_num_colors(timeout):
Attempt to determine the number of colors we are able to query from
the terminal. timeout is measured in milliseconds and has the same
interpretation as in rgb_query. A larger timeout is safer but will
cause this function to take proportionally more time.
if not test_color(timeout):
return 0
a = 0
b = 1
while test_rgb_query([4, b], timeout):
a = b
b += b
while b - a > 1:
c = (a + b)>>1
if test_rgb_query([4, c], timeout):
a = c
else:
b = c
return b
class ColorDisplay(object):
Class for producing a colored display of terminal RGB values.
def __init__(self, timeout=100, color_level=3, do_query=True):
timeout: same interpretation as in rgb_query. A larger timeout
will be used a small number of times to test the
capabilities of the terminal.
color_level: how much color should be in the output. Use 0 to
suppress all color and 3 or greater for maximum coloredness.
do_query: whether to attempt to query RGB values from the
terminal or just use placeholders everywhere
self.timeout=timeout
self.color_level=color_level
# try getting the rgb value for color 0 to decide whether to
# bother trying to query any more colors.
self.do_query = do_query and test_color(self.timeout*5)
def none_factory():
return None
# colors for highlighting
self.hi = defaultdict(none_factory)
self.hi['['] = 10
self.hi[']'] = 10
self.hi['+'] = 9
self.hi['/'] = 9
for c in '0123456789ABCDEF':
self.hi[c] = 12
def show_ansi(self):
Show the 16 ANSI colors (colors 0-15).
color_order = [0, 1, 3, 2, 6, 4, 5, 7]
names = [' Black ', ' Red ', ' Green ', ' Yellow ',
' Blue ', ' Magenta', ' Cyan ', ' White ']
stdout.write(self.fgcolor('15', 3))
for k in range(8):
a = color_order[k]
stdout.write(names[a])
stdout.write('\n')
stdout.write(self.fgcolor(None, 3))
c = None
for k in range(8):
a = color_order[k]
c = self.hiprint(' [%X/%X] ' % (a, 8 + a), c)
stdout.write('\n')
self.show_color_table([0,8], color_order)
def show_color_cube(self, n):
Show the "RGB cube" (xterm colors 16-231 (256-color) or 16-79
(88-color)). The cube has sides of length 6 or 4 (for 256-color
or 88-color, respectively).
base = {256:6, 88:4}[n]
c = None
c = self.hiprint('[ + ] ', c)
for w in range(base):
c = self.hiprint('[%X] ' % w, c)
stdout.write('\n\n' + self.fgcolor(None, 3))
for u in range(base):
for v in range(base):
stdout.write(' '*v)
x = (u*base + v)*base
self.hiprint(' [%02X] ' % (16 + x))
for w in range(base):
self.show_color(x + w + 16)
stdout.write('\n')
stdout.write('\n\n')
def show_grayscale_ramp(self, end):
Show the "grayscale ramp" (xterm colors 232-255 (256-color) or
80-87 (88-color)).
start = {256:232, 88:80}[end]
n = end - start
vals = [self.get_color(a) for a in range(start, end)]
#stdout.write(reset)
c = None
c = self.hiprint('[ ', c)
for v in range(n):
c = self.hiprint('%02X ' % (start + v), c)
c = self.hiprint(']\n', c)
stdout.write('\n ' + self.fgcolor(None, 3))
for v in range(n):
stdout.write(' ' + self.block(start + v, 2))
stdout.write('\n ')
for u in range(3):
for v in range(n):
stdout.write(' ')
stdout.write(self.fgcolor(start + v, 2))
stdout.write(vals[v][2*u : 2*(u + 1)])
stdout.write(self.fgcolor(None, 2))
stdout.write('\n ')
stdout.write('\n')
def show_colors(self, n):
Make a table showing colors 0 through n-1.
self.show_color_table(range(0,n,8), range(8), n, True)
def show_color_table(self, rows, cols, stop=-1, label=False):
Make a color table with all possible color indices of the form
rows[k] + cols[j] that are less than `stop' (if `stop' is not
negative). If label is True, then print row and column labels.
if label:
self.hiprint('[ + ]')
stdout.write(self.fgcolor(None, 3))
for a in cols:
stdout.write(' ' + self.octal(a) + ' ')
stdout.write('\n')
if label:
stdout.write(' ')
stdout.write('\n')
for b in rows:
if label:
stdout.write(self.octal(b) + ' ')
for a in cols:
c = a + b
if stop < 0 or c < stop:
self.show_color(b + a)
else:
stdout.write(' ')
stdout.write('\n')
stdout.write('\n')
def show_color(self, a):
Make a pretty display of color number `a', showing a block of
that color followed by the 6-character hexadecimal code for the
color.
stdout.write(' ' + self.block(a) + ' ')
stdout.write(self.fgcolor(a, 2) + (self.get_color(a)))
stdout.write(self.fgcolor(None, 2))
def hiprint(self, s, last_color=-1):
Print s to stdout, highlighting digits, brackets, etc. if the
color level allows it.
Arguments:
s: the string to print.
last_color: the current terminal foreground color. This
should be `None' if no color is set, or the current
color index, or something else (like a negative integer)
if the color isn't known. (The last option is always
safe and will force this function to do the right
thing.)
Return: the current foreground color, which can be passed as
last_color to the next call if the color isn't changed in
between.
for c in s:
if c == ' ':
color = last_color
else:
color = self.hi[c]
if color != last_color:
stdout.write(self.fgcolor(color, 3))
stdout.write(c)
last_color = color
return last_color
def octal(self, x):
Return a base-8 string for the integer x, highlighted if the
color level allows it.
return self.fgcolor(self.hi['+'], 3) + '0' + \
self.fgcolor(self.hi['0'], 3) + ('%03o' % x)
def block(self, c, n=1):
Return a string that prints as a block of color `c' and size `n'.
return self.bgcolor(c, 1) + ' '*n + self.bgcolor(None, 1)
# Changing the foreground and background colors.
# While the 38;5 and 48;5 SGR codes are less portable than the usual
# 30-37 and 40-47, these codes seem to be fairly widely implemented (on
# X-windows terminals, screen, and tmux) and support the whole color
# range, as opposed to just colors 0-8. They also make it very easy to
# set the background to a given color without needing to mess around
# with bold or reverse video (which are hardly portable themselves).
# This is useful even for the 16 ANSI colors.
def fgcolor(self, a=None, level=-1):
Return a string designed to set the foreground color to `a' when
printed to the terminal. None means default.
if self.color_level >= level:
if a is None:
return csi + '39m'
else:
return csi + '38;5;' + str(a) + 'm'
else:
return ''
def bgcolor(self, a=None, level=-1):
Return a string designed to set the background color to `a' when
printed to the terminal. None means default.
if self.color_level >= level:
if a is None:
return csi + '49m'
else:
return csi + '48;5;' + str(a) + 'm'
else:
return ''
def get_color(self, a):
if self.do_query:
try:
return get_color(a, timeout=self.timeout)
except (InvalidResponseError, NoResponseError):
return rgb_placeholder
else:
return rgb_placeholder
# Command-line arguments
timeout_dft = 200
parser = ArgumentParser(
description="Python script to show off terminal colors.",
epilog="Run this script from the terminal whose colors " +
"you want to showcase. " +
"For a brief synopsis of which terminal types are " +
"supported, see the top of the source code.")
mode_group = parser.add_mutually_exclusive_group()
p_choices = [16, 88, 256]
arg_p = mode_group.add_argument(
'-p', '--pretty',
action='store_true', default=False,
help="show colors 0 through N-1 in a pretty format. " +
("N must belong to %r. " % p_choices) +
"If N > 16, it should be the actual number of colors " +
"supported by the terminal, or the output will almost " +
"certainly not be pretty.")
mode_group.add_argument(
'-f', '--flat',
action='store_true', default=False,
help="show a simple table with colors 0 through N-1. ")
parser.add_argument(
'n', nargs='?', metavar='N',
type=int, default=16,
help="number of colors to show. " +
"Unless you explicitly supply -p/--pretty or -f/--flat, " +
"--pretty is used if possible and --flat is used " +
"otherwise. " +
"N defaults to 16, showing the ANSI colors 0-15. " +
"If N is 0, the script will attempt to determine the " +
"maximum number of colors automatically " +
"(which may be slow).")
parser.add_argument(
'--no-fgbg',
action='store_false', dest='fgbg', default=True,
help="suppress display of foreground/background colors.")
parser.add_argument(
'--no-query',
action='store_false', dest='do_query', default=True,
help="don't try to query any RGB values from the terminal " +
"and just use placeholders.")
parser.add_argument(
'-t', '--timeout', metavar='T',
type=int, default=timeout_dft,
help="how long to wait for the terminal to "
"respond to a query, in milliseconds " +
"[default: {0}]. ".format(timeout_dft) +
"If your output has '?' characters " +
"instead of RGB values " +
"or junk printed after the script runs, " +
"increasing this value may or may not " +
"help, depending on the terminal. " +
"A negative T will behave like infinity.")
parser.add_argument(
'-l', '--level', metavar='L',
type=int, default=3,
help="choose how much color to use in the output. " +
"(0 = no color; 3 = most color [default])")
if __name__ == '__main__':
args = parser.parse_args()
assert not (args.pretty and args.flat)
if args.pretty:
if args.n not in p_choices:
raise ArgumentError(
arg_p,
"N must belong to %r" % p_choices)
tc_save = None
try:
tc_save = termios.tcgetattr(stdout.fileno())
tc = termios.tcgetattr(stdout.fileno())
# Don't echo the terminal's responses
tc[3] &= ~termios.ECHO
# Noncanonical mode (i.e., disable buffering on the terminal
# level)
tc[3] &= ~termios.ICANON
# Make input non-blocking
tc[6][termios.VMIN] = 0
tc[6][termios.VTIME] = 0
termios.tcsetattr(stdout.fileno(), termios.TCSANOW, tc)
if args.n == 0:
args.n = test_num_colors(args.timeout)
# We are guaranteed to have failed some queries now, but
# that isn't meaningful.
num_errors = 0
if not (args.pretty or args.flat):
if args.n in p_choices:
args.pretty = True
else:
args.flat = True
if args.level >= 1:
stdout.write(reset)
if args.fgbg:
if args.do_query:
try:
bg = get_bg(timeout=args.timeout)
except (InvalidResponseError, NoResponseError):
bg = rgb_placeholder
try:
fg = get_fg(timeout=args.timeout)
except (InvalidResponseError, NoResponseError):
fg = rgb_placeholder
else:
bg = rgb_placeholder
fg = rgb_placeholder
stdout.write("\n Background: %s\n" % bg)
stdout.write(" Foreground: %s\n\n" % fg)
C = ColorDisplay(args.timeout, args.level, args.do_query)
if args.pretty:
assert args.n in p_choices
stdout.write('\n ANSI colors:\n\n')
C.show_ansi()
if args.n > 16:
stdout.write('\n RGB cube:\n\n')
C.show_color_cube(args.n)
stdout.write(' Grayscale ramp:\n\n')
C.show_grayscale_ramp(args.n)
else:
C.show_colors(args.n)
if num_errors > 0:
stderr.write("Warning: not all queries succeeded\n" +
"Warning: (output contains " +
"placeholders and may be inaccurate)\n")
finally:
if args.level >= 1:
stdout.write(reset)
flush_input()
if tc_save != None:
termios.tcsetattr(stdout.fileno(),
termios.TCSANOW, tc_save)
Run it as
python showcolors.py -h
to get an overview of the functionality.
TL;DR: you can echo a string like "\033]4;13;?\007" to an xterm, and it will output the RGB value of color #13 to itself in the form "\033]4;13;rgb:rrrr/gggg/bbbb\007", which you can then read and parse. To try it out:
$ echo -en "\033]4;13;?\007"
There are some subtleties if you want this to work on other terminals like urxvt; for that you can experiment yourself or read the code.
Further reading: http://invisible-island.net/xterm/ctlseqs/ctlseqs.html (heading "Operating System Controls").
Xyne, regarding determining the number of colors: I don't know how to do that completely reliably. You can try simply
tput colors
but this relies on the value of $TERM and its terminfo and thus may be unreliable. A kludgy but workable way to do this using the "rgb_query" function in my script is to query color values using binary search to find the highest color value the terminal will allow you to query. The main problem with this is that if you query an invalid color index, then the terminal just won't respond at all, and if you query a valid index, it will respond but after a somewhat unpredictable delay, so it's hard to know for sure which one is the case. Like I said, it's kludgy but workable.
Edit: I went ahead and added that functionality to my script. Try running it as
python showcolors.py 0
or look at the function "test_num_colors".
Last edited by Lux Perpetua (2012-10-22 11:18:21) -
How to restrict metadata to use only view values
I have a metadata which takes values from view, i want to restrict it's value to use only view values( as it is editable , user can type any value , and right now it is allowing any value but i want to restict it to use only view values.
Thanks.Hi Chely,
Try doing below steps and let us know if this solves the problem
Log in to WCC
Click on Administartion --> Admin applets --> configruation manager
Choose the metadata value for which you have problem
Click on Edit
Click on Configure button next to Enable Option List
What value do you see in Option List Type?
Change it to Select List validated and see if problem persists.
regards,
Deepak -
TELNET or Hyper Terminal Application
Id like to use the ibook G4 to log technical data from a device using the USB - I've done this in the past using a PC and the RS232 port while using the "Hyper Terminal" application.
Question : Is there a MAC equivalent application for this purpose?You might be able to find something here...
http://www.pure-mac.com/remote.html -
Flexfield View Generator Program Was Terminated With Signal 11
Hi All,
After compiling any flexfield, the Flexfield View Generator concurrent program is getting initiated which is completing with error status with the following log message:
/oracle/findev1/APPS/R12/apps/apps_st/appl/fnd/12.0 .0/bin/FNDFFVGN
Program was terminated by signal 11.
Need help related to the root cause of the error.
Thanks,
Chandra.Please see these docs.
During Patch FNDFFVGN Fails With EMSG Message And Signal 11 [ID 1364773.1]
12.1 Upgrade Has Invalid KFV With VIEW_HAS_FAILED_CHECK_LOG_FILE [ID 975083.1]
If you still have the same issue, please relink FNDFFVGN via adadmin and check then -- 11i : How To relink a single executable via ADADMIN Utility [ID 388198.1]
Thanks,
Hussein -
TPM: planning view - value distribution
Hi Gurus,
I have a requirement where the entered advert contribution as a trade spend must be distributed evenly among the assigned products.
We will do the planning either at product or product group level. We use the standard planning profile 4TPM0002 in our trade promotions. When the planning view is displayed we don't have an agregated total line so we have to manually distribute the cost among the assigned products. No automatically distribution takes place. So my question is:
Do I have to set up value distribution in the IMG (SPRO->SAP Reference IMG-> Customer Relationship management->Marketing->Marketing planning and campaign management->Key figure planning->*Maintain value distribution)
Is the above configuration also applicable for TPM or do we have to set up distribution from aggregate level in BPS?
I have the same issue with the uplift to APO.
Regards
AnneHello Anne,
Mentioned path is for campaigns only.that is beacause Distribution to target objects is only provided for campaigns and campaign elements.
To answer your Question, you have to set up distribution from aggregate level in BPS.
Thanks
Raja Pamireddy
CRM Marketing Forum Moderator. -
View value of NEXT parameter of data file
Good day!
How can I view|query value of NEXT parameter (property of data file)
For example, when I create tablespace or add datafile, I can set up value for this parameter:
create tablespace ....
autoextend on
next 10M
Bun I couldn't find value of this parameter in any table of view.I think it is right for tablespace scope, but not for datafile, because tablespace may consist of several datafiles
I find useful information in dba_data_files table and INCREMENT_BY column (in db blocks) -
Hi : )
How do I view whether AFP is enabled or not via the terminal?
I thought I could view /etc/hostconfig to get the answer when logged in via e.g. SSH. But in Leopard running the following terminal command:
cat /etc/hostconfig | grep "=\-" | sort
Always shows AFPSERVER as NO whether or not file sharing is turned on or not.
At the top of this file, it says #this file is going away. So I'm guessing there is another / better way to view this.
Hunting around a bit, I found that if I:
netstat -a
and filesharing is running, there are two entries *.afpovertcp and *.afpovert in the output.
tcp4 0 0 *.afpovertcp . LISTEN
tcp6 0 0 *.afpovert . LISTEN
Turning off filesharing removes these from netstat.
Doing the above command takes a few seconds to get a result as it seems to poll a whole range of different services and protocols, which as I'm calling this from a script I don't have time for, so if I:
netstat -a -f inet6 | grep afp
I get a near instantaneous result of:
tcp6 0 0 *.afpovert . LISTEN
if filesharing is turned on and null if it is turned off.
Can anyone point me in a different direction? Is there another way? Or is this as good as any?
Thanks...Actually, after further review, this method doesn't work as it only returns the last log entry for AFP status rather than the current status.
E.g. the last log entry could be AFP Control: AFP Error but if the computer is then restarted, AFP Control doesn't get logged in the system log on restart. Hence the egrep command still returns: AFP Error, when in fact AFP is actually enabled and running.
Hence back to my original question! anyone know a way to view if FileSharing is currently active via the terminal, even when there are no connected users other than:
netstat -a -f inet6 | grep afp
and looking for:
tcp6 0 0 *.afpovert . LISTEN
as the result??? Or is this a reliable method? i.e. if afpovert is present is that a hard and fast way of discovering filesharing is enabled?
Message was edited by: cjcj -
Hi ,
I have 4 views and have a following issue with it as below ...
View 2 - Have Date Field based up this Leave Calculation are based and will be displayed in View 3.
View 3 - Have Leave input box where the user can chage the leave hrs.
View4- Have Address details.
Each View have 'Back' & 'Continue' buttons . The when i am navigating view2 to view3 Leave Input box populates the correct value , even when i am back to View2 and change the date its popultes the correct value to View3.
The Problem is when i change the Leave Value in View3 and hit continue to View4 and then tried navigating back to the View3 the Leave Value in view3 changes to old value rather than the inputted value . Have written the code in 'handlein' event & WDINIT of view3 to calcualte and populate the Leave value on View3 . Any suggestion on this Please.
Thanks,
KumarHi,
If you want to have the newly inserted values to be reflected in the UI elements when navigated from view to other then write the code in the respective Handlers of the plugs.
Try to use the global variables in the component controller context. if you write the code in the WDDOINIT, then only once it is triggered. Hence you can not see the updated values.
If you want to have new values then use the GET_ATTRIBUTE and SET_ATTRIBUTE of that context attribute.
Or else try to pass these parameters through the plugs to have the new values when navigated from back and forth from one view to other.
When navigated from view3 to view4 then write the code in the Input handler of view4 and write the code in the
handler when navigated from view4 to view3. WDDOINIT of view code gets triggered only once in the entire session.
Regards,
Lekha. -
Viewing values passed vide a Transport Request
Hi Consultants,
I have done an IMG activity. I changed a value in configurations table. It created a Transport request. How can I view the value it is going to pass to the target system. In SE01 transactions, in drill down, I can go till the table - Key fields only.. it does not diplay the value it captured in the request. Is there any away to view that in the source system OR in the traget system after the import. Please suggest.
Thanks
RajaHello,
You have posted a question that is related to system transports. Unfortunately this category is not related to these kind of questions. SAP TM deals with logistics in the real world - moving pallets, containers, loading trucks, etc.
To learn more about SAP TM please visit [http://service.sap.com/scm-tm|http://service.sap.com/scm-tm]
Therefore I will now move this thread to the category Software Logistics. Thank you for your understanding.
Kind regards,
Nico van Os.
Maybe you are looking for
-
I have an airport express that I used in another location. I brought it home and want to use it with my existing network and time capsule to do AirTunes. I can't get the Express to show up in my airport utility to even set it up. Do I need to conn
-
Folio builder panel error in windows
hi, i have a problem...i have indesign and i work in windows but when open folio builder produce one error and close indesign...what's happens?
-
Trouble Importing Canon XF Files at 1080 60i (59.94i)?
I am completely new with Premiere Pro and editing in HD for that matter. I am still using the trial version of Premiere Pro CS5.5. My issue is that I shoot on an Canon XF300 at 1080 60i. When selecting a new project I select the following Preset [Can
-
How to find row changes in table
How can we find row changes in table and i want o find out any significant change in the row information in 11g db.
-
Hi All, I have created a driver program and I have two smart forms , The thing is like from one driver program i want to executed two smart forms where logic is almost same for the both the forms.So put me some code lines if possible . with