teraterm script constructing a string that is the same name as a constant - ttl

I have defined the constant registers with the following addresses:
MDIO3_CTL = '0x08c0f034'
MDIO4_CTL = '0x08c13034'
... etc.
Based on the MDIO number (ex: 3 or 4), I want to do a memory display (md) of that register.
macnum ='3'
mac = 'MDIO'
strconcat mac macnum
strconcat mac '_CTL'
sendln 'md ' mac ' 1 '
wait Uboot
When I do the sendln, I see 'md MDIO3_CTL 1' instead of 'md 0x08c0f034 1'. Can someone help me?

Related

Sending command to GPS device using gpsd python library

I use the gpsd python library in order to read and parse the NMEA string recieved from the gps device. I would like to send some command to gps in order to fine tune the measurement rate, report rate and so on.
It is possible using the gpsd library or I must send the command with in other way?
According to 'gpsd' manual:
To send a binary control string to a specified device, write to the
control socket a '&', followed by the device name, followed by '=',
followed by the control string in paired hex digits.
So if you have gpsd service running as gpsd -F /var/run/gpsd.sock you can use the following code to send commands to the gps device:
import socket
import sys
# Create a socket
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
# Connect the socket to the port where the GPSD is listening
gpsd_address = '/var/run/gpsd.sock'
sock.connect(gpsd_address)
# #BSSL 0x01<CR><LF> - Set NMEA Output Sentence (GGA only)
# cmd = '#BSSL 0x01' + '\r\n'
# #RST<CR><LF> - RST - Reset
cmd = '#RST' + '\r\n'
message = '&/dev/ttyUSB1='
cmd_hex = cmd.encode('utf-8').hex()
print ('cmd_hex {}'.format(cmd_hex))
# cmd_hex 405253540d0a
message += cmd_hex
bin_message = message.encode('utf-8')
print ("bin message {}".format(bin_message))
# bin message b'&/dev/ttyUSB1=405253540d0a'
sock.sendall(bin_message)
data = sock.recv(16)
print ('received {}'.format(data))
# received b'OK\n'
sock.close()
In my case I am sending #RST command followed by CR, LF symbols.

QB64 Open Com port causes data read error

There seems to be a fundamental problem with QB64 Open Com statement at least with my compiler. When I open the com port with OPEN "Com3: 9600,n,8,1,ds0,cs0,rs" FOR RANDOM AS #1 while knowing that there is data in the buffer and print EOF, LOC, LOF. It shows EOF=0 OK fine but LOC and LOF both show 0. If you then exercise a GET statement you get a "bad record length" because LOF=0. If I use OPEN FOR INPUT then I immediately get EOF=-1, LOF and LOC=0. If I then use INPUT# I get an input past end of file error because EOF was already -1.
I know that the buffer contains" Voltage = 1.2* "(no quotes) If I say continue upon the input past end of file error I actually get Part of the message.
Is there a fix for this com port problem?
If you test the com port you will find Windows nicely blocks those ports:
REM test com port keyboard i/o
OPEN "COM3:9600,N,8,1,BIN,CS0,DS0" FOR RANDOM AS #1
DO
IF LOC(1) THEN
GET 1, , x
PRINT CHR$(x);
END IF
x$ = INKEY$
IF LEN(x$) THEN
IF x$ = CHR$(27) THEN END
x = ASC(x$)
PUT 1, , x
END IF
LOOP
END

DotNetZip zipping files with Arabic names

When creating a zip file out of many Arabic named files, I have as prompted in DotNetZip's FAQ changed the code page to the following:
Using zip As New ZipFile()
zip.AddDirectoryByName("Files")
zip.AlternateEncoding = Encoding.UTF8
zip.AlternateEncodingUsage = Ionic.Zip.ZipOption.Always
Dim row As Integer
For row = 0 To ds.Tables("d").Rows.Count - 1
fileToDownload = Server.MapPath("~/.../Resources/Attachments/" + ds.Tables("d").Rows(row).Item(1).ToString)
zip.AddFile(fileToDownload, "Files")
Next
Response.Clear()
Response.BufferOutput = False
Dim zipName As String = [String].Format(gvRow.Cells(8).Text.Trim + ".zip")
Response.ContentType = "application/zip"
Response.AddHeader("content-disposition", "attachment; filename=" + zipName)
zip.Save(Response.OutputStream)
Response.[End]()
End Using
I have used several listed Arabic encoding codes, but most of them produce '???' whereas this one produces names as the following: '¦ßs-¦ µ+++ ¦ß+pß.docx'
What is the correct code to be used? Or am I missing something?
Use UTF8 Encoding and pass it as parameter to the constructor:
IO.File.Delete("D:/testZip.zip")
Using zip As New Ionic.Zip.ZipFile(Encoding.UTF8)
zip.AddDirectory("d:/out")
zip.Save("D:/testZip.zip")
End Using
this code works with me with Arabic file names (windows 7).
EDIT #1 : you must force DotNetZip to use the specified encoding by using Always option instead of AsNesseary :
IO.File.Delete("D:/testZip.zip")
Using zip As New Ionic.Zip.ZipFile()
zip.AlternateEncoding = Encoding.UTF8
zip.AlternateEncodingUsage = Ionic.Zip.ZipOption.Always
zip.AddDirectory("d:/out")
zip.Save("D:/testZip.zip")
End Using
EDIT #2 : based on your comment, I think your operating system does not support Arabic UI,for windows 7 professional 32 bit, go to Control Panel -> Region and Language -> Administrative [tab] -> click "change System locale" button -> choose "Arabic Egypt" for Example -> OK -> OK (restart computer is needed) , Don't worry, the language of windows 7 still English.
EDIT #3 : As I mentioned in EDIT #2, your system must support Arabic UI, for example, create a file called (ملف جديد) then add it to archive using WinZip or Winrar, then open the generated archive, if you can read file names correctly , then try to use one of the following encodings in your code :
Encoding.Unicode
Encoding.UTF7
Encoding.UTF8
Encoding.UTF32
If you are unable to read Arabic file names inside the generated archive, you must configure your system to support Arabic UI.
Also, please use the following order for these lines, put the Encoding, then add files or folders :
zip.AlternateEncoding = Encoding.UTF8
zip.AlternateEncodingUsage = Ionic.Zip.ZipOption.Always
zip.AddDirectoryByName("Files")
After using what seemed like a myriad of trials using code pages, simply replacing this:
zip.AlternateEncoding = Encoding.UTF8
with this:
zip.AlternateEncoding = Encoding.GetEncoding(720)
worked.

Why would CPCL code sent to a Zebra QLn220 printer work, whereas the same code does NOT work when sent to a Zebra QL220?

Based on user preferences (type of label selected, and whether to send a "Keep Alive" message), different CPCL commands are sent from a handheld device to a Zebra QL[n]220 belt printer. This code:
const string quote = "\"";
string keepPrinterOn = string.Format("! U1 setvar {0}power.dtr_power_off{0} {0}off{0}", quote);
string shutPrinterOff = string.Format("! U1 setvar {0}power.dtr_power_off{0} {0}on{0}", quote);
string advanceToBlackBar = string.Format("! U1 setvar {0}media.sense_mode{0} {0}bar{0}", quote);
string advanceToGap = string.Format("! U1 setvar {0}media.sense_mode{0} {0}gap{0}", quote);
...works for the (newer) QLn220 printer, but on the (older) QL220, rather than the printer receiving the commands and acting on them, it simply prints the raw commands onto the labels. IOW, the QL220 belt printer, instead of converting the commands to actions, or barcodes, it prints stuff like this directly on the label:
0 200 200 241 1
RIGHT
TEXT 4 3 0, 0 0.75
LEFT
TEXT 5 0 0 90 DRPEPPER (7X2) = 14
CENTER
BARCODE UPCA 1 1 50 0 137 054900000295
FORM
PRINT
Is it that something changed between the QL220 and the QLn220 as to the CPCL protocol, or...???
UPDATE
Well, this is bizarre; oddly enough, I added this code:
string getDeviceLang = string.Format("! U1 getvar {0}device.languages{0}", quote);
string setDeviceLangZPL = string.Format("! U1 setvar {0}device.languages{0} {0}ZPL{0}", quote);
. . .
String deviceLanguage = PrintUtils.GetSettingFromPrinter(getDeviceLang);
MessageBox.Show(deviceLanguage);
if (deviceLanguage.Equals("line_print"))
{
PrintUtils.SendCommandToPrinter(setDeviceLangZPL);
}
...and although the call to GetSettingFromPrinter() returns an empty string (as seen in MessageBox.Show), the printing therefater works as desired anyway (it prints the labels as desired, instead of just printing the raw commands onto them)!?
UPDATE 2
Note: My QLn220 Zebra printer does have a usb port (the older QL220, which is the one that was causing the problems, does not). When I sent it the "what language are you using" (getDeviceLang) command using Zebra Setup Utils, it responded with, "hybrid_xml_zpl"
Hybrid zpl combines both CPCL and ZPL print commands.
Receipt printers (imz, em220...etc) are set originally from factory in Line print mode. Some of the older QL220 are as well. Its best to set them to Hybrid and you should have no problems.
Brent
Arrowhead Corp - Zebra ISV

LabVIEW: Extract data after a certain line

Any advice or help would be much appreciated.
Question: How to extract data after a certain line from a comma deliminated strings which are read from a serial port ?
More Info: A have a card that is gathering data values and is read into the computer via a serial port. Example string of data acquired as below:
;Data = 1 bps Tool = Sensor
;Label, Time, Voltage, Pressure, Temperature, Current
A, 01:33, 5.1, 18.1, 31.2, -,
B, 01:34, 5.5, 19.2, 30.5, -,
;Data = 1 bps Tool = Sensor
;Label, Time, Voltage, Pressure, Temperature, Current
A, 01:35, 5.3, 18.3, 30.1, -,
B, 01:36, 5.1, 19.0, 30.5, -,
;Data = 1 bps Tool = Sensor
;Label, Time, Voltage, Pressure, Temperature, Current
A, 01:37, 5.1, 18.1, 30.8, -,
B, 01:38, 5.3, 19.2, 30.1, -,
These data value will be kept updating line by line. I would like to start extracting the data only on the 3rd block of incoming data. I would not want the first 2 blocks of incoming data.
Further Info: Currently, my idea of doing that is to scan the ";Data" and put it into a counter. If there are 2 ";Data" scan, then from the counter it woud output a True value to a case structure to start extracting the data. Please see my attached photo.
However, I am not able to create such a counter using an array as I cannot use a while loop and shift register. Do you have any idea how to start extracting data from 3rd block onwards ? Thank you very much.
Hopefully I understand the question properly. Here is my solution:
Code can be found here: http://raptorview.net/StackOverflow/SO19920265.vi