ZPL: RFID, Combining Field Data (^FD) and Field Numbers (^FN) - rfid

I am attempting to encode the EPC of a GS1 RFID using ZPL statements on a Zebra 410R printer.
First, consider the following ZPL :
^FD51,0,6,111111,2,33,444^FS
What I am attempting to do, is replace the 444 with a value stored in a field number (^FN).
^XA
^DFE:RFID^FS
^RB96,8,3,3,20,24,10,28
^RFW,E
^FD51,0,6,111111,2,33,^FN11"Enter Barcode"^FS
^XZ
So, How do I replace the '444' portion of the field data with the value stored in the field number (^FN11) ?
Thank you in advance.

Well, maybe a little bit too late, but to anyone, who may have the same question - DF is a pair command, you need to pair it with XF. DF is Download format - here you use the varible ( FD, FN). XF is Recall Format - here you declare the variables.
So, your code just miss the definition of variable, here is the whole code:
Your code:
^XA
^DFR:RFID^FS
^RB96,8,3,3,20,24,10,28
^RFW,E
^FD51,0,6,111111,2,33,^FN11"Enter Barcode"^FS
^XZ
^XA
^XFR:RFID
^FN11^FN444^FS
^XZ

Related

cantools.database.errors.Error: Standard frame id is more than 11 bits

I used cantools python package to decode canbus message. I used a dbc file created by me for testing. I copied a sample file. When I use can id like 419358976, I get error. But for smaller can ids like 350, it works. Does cantools fail for extended frame ids? how do I get this working?
my code which is failing for extended id's is as follows:
db = cantools.database.load_file('.\\src\\test\\resources\\j1939.dbc')
print(db.decode_message(419358976,b'\xff\xff\xff\xc0\x0c\xff\xff\xff'))
error: cantools.database.errors.Error: Standard frame id 0x18fee900 is more than 11 bits in message EEC1.
I found the answer for my question. The can id like 419358976 is an extended id. So to map that id to the id in the dbc file, I need to add another 32 bit hex number 8000 0000 to the hex can id. Then convert that result hex number to decimal and use it as the id field in the dbc file. It works perfectly after. The above error message is gone after

Skip element in BizTalk flat file assembly?

I've been tasked to map an input xml (actually an SAP idoc xml), and to generate a number of flat files. Each input xml may yield multiple output files (one output file per lot number), so I will be using xsl:key and the key() function in my mapping, based on the lot number
The thing is, the lot number itself will not be in the file itself, but the output file name needs to contain that lot number value.
So the question really is: can I map the lot number to the xml and have the flat file assembler skip it when it produces the file? Or is there another way the lot number can be applied as file name by the assembly without having it inside the file itself?
In your orchestration you can set a context property for each output message:
msgOutput(FILE.ReceivedFileName) = "DynamicStuff";
msgOutput then goes to the send shape.
In your send port you set the output file like this:
FixedStuff_%SourceFileName%.xml
The result:
FixedStuff_DynamicStuff.xml
If the value is not required in the message content, don't map it. That's it.
To insert at value in the file name, lot number in this case, you will need to promote that value to the FILE.ReceivedFileName Context Property. Then, you can use the %SourceFileName% Macro as part of the name setting in the Send Port. You can set FILE.ReceivedFileName by either Property Promotion or xpath() in an Orchestration.
Bonus: Sorting and Grouping in xslt is rather unwieldy, which is why I don't do that anymore. Instead, you can use SQL: BizTalk: Sorting and Grouping Flat File Data In SQL Instead of XSL

How to visualize a count of all values in an array field in Kibana

I am having trouble creating a particular type of visualization in Kibana. My events in Kibana are statistics on communications between two ip address. Two of the fields are lists of ports used by the particular ip address. An example of the fields would be:
ip1 = 192.168.101.2
ip2 = 192.168.101.3
ip2Ports = 80,443
ip1Ports = 80,57000,0
I would like to have a top count of all the values such as
port count
80 2
57000 1
443 1
I have been able to parse ip2Ports to be ip2Ports_List.column1, ip2Ports_List.column2, ect, but I can only choose one term with term aggregation in the visualization. I can split the chart, but that leads to separate counts for each field. If I go by the original ip2Ports field, it is just aggregated as the string such as, "80,443".
Is it even possible to create a top count visualization of fields with multiple values? If so, how would I do so. If not, is there a way to restructure my data so I can do it? Thank you!
My issue stemmed from the format of the values being sent in by Logstash. I had thought that the 'ip2Ports_List.column1' format, which was a result from using the csv filter, was part of an array. It wasn't. After analyzing it, 'ip2Ports_List.column1' didn't seem to be much different from a new field.
Elastic needed an array to give me the visualization I wanted. I wasn't sure what the best way to produce it was, so I just ended up using the ruby filter. This is what the code ended up looking like:
ruby {
code => "fields = event.get('portsIp').split(',')
event.set('portsIpArray',fields)"
}
Where 'portsIp' looked something like "80,443". Splitting it turned 'portsIp' into a Ruby array. I just set that array as the value for a new event field, 'portsIpArray'.
From there when I tried visualize the 'portsIpArray' field, it looked exactly how I wanted it to, treating each port as separate value, and still associating each port with the same event/field.
Extra:
Also something I discovered is if you're writing your code like I was, directly in the Logstash conf file, Logstash doesn't like it if you use double quotes within the double quoted code. In hindsight it makes sense, but it doesn't give a clear error so it's difficult to figure out.

Not using colnames when reading .xls files with RODBC

I have another puzzling problem.
I need to read .xls files with RODBC. Basically I need a matrix of all the cells in one sheet, and then use greps and strsplits etc to get the data out. As each sheet contains multiple tables in different order, and some text fields with other options inbetween, I need something that functions like readLines(), but then for excel sheets. I believe RODBC the best way to do that.
The core of my code is following function :
.read.info.default <- function(file,sheet){
fc <- odbcConnectExcel(file) # file connection
tryCatch({
x <- sqlFetch(fc,
sqtable=sheet,
as.is=TRUE,
colnames=FALSE,
rownames=FALSE
)
},
error = function(e) {stop(e)},
finally=close(fc)
)
return(x)
}
Yet, whatever I tried, it always takes the first row of the mentioned sheet as the variable names of the returned data frame. No clue how to get that solved. According to the documentation, colnames=FALSE should prevent that.
I'd like to avoid the xlsReadWrite package. Edit : and the gdata package. Client doesn't have Perl on the system and won't install it.
Edit:
I gave up and went with read.xls() from the xlsReadWrite package. Apart from the name problem, it turned out RODBC can't really read cells with special signs like slashes. A date in the format "dd/mm/yyyy" just gave NA.
Looking at the source code of sqlFetch, sqlQuery and sqlGetResults, I realized the problem is more than likely in the drivers. Somehow the first line of the sheet is seen as some column feature instead of an ordinary cell. So instead of colnames, they're equivalent to DB field names. And that's an option you can't set...
Can you use the Perl-based solution in the gdata instead? That happens to be portable too...

Serial Port Communication

I want to send data hex format (0x01) or (0xff) to the port where rs232 cable is connected. I am using the MSCOMM control in VC++ 6.0. Is that the correct way to send the hex data. This is the code I have.
CString output;
UCHAR data1,data2;
data1=0x01;
output.Format("%x",data1);
m_mscom.SetOutput(COleVariant(output));
data2=0xff;
output.Format("%x",data2);
m_mscom.SetOutput(COleVariant(output));
If it is not correct, please tell me how to send hex format data to the port.
Thanks in Advance
If your data is simply a hex value that you want to send out (as opposed to a hex formatted string), you probably want "%c" rather than "%x". Given a data value of (e.g.) 0x65, "%x" will produce two bytes on the serial port: '6' (ascii value 54) and '5' (ascii value 53). "%c" will produce a single byte on the serial port: 'e' (ascii value 100 or 0x65).
As far as sending data on a serial port in C, have a look at CSerial or CSerialPort: they may simplify things for you a bit (note that I've not used them, I tend to do serial port apps in python with the pyserial module or in wxWidgets with the ctb library).
Edit: The other one that's quite good (I have used it before, but couldn't find the link when I wrote the original post) is CSerialFile, part of the WFC libraries. As I said, I tend to use wxWidgets now, but if you're using the Microsoft foundation classes, CSerialFile does make serial access very easy.
I'm no familiar with MSCOM but it seems like it won't work. Format may re-format the data to an ASCII string representation instead.
Alternatively, you can just use any serial port as a 'file' in Windows. Look at the windows api for opening files and you will see that you can address certain devices as files by using a filename like 'COM1:' instead.
Then, you can read/write from it like a file.

Resources