General Category > Tips & Tricks
ControlLogix ReadUDT and WriteUDT
dmroeder:
--- Quote from: Archie on January 07, 2021, 09:39:40 PM ---
--- Quote from: marcowy on January 06, 2021, 05:07:08 PM ---According to this SINT = SByte. But what about USINT? Can I delcare it as Byte and read/write it with ReadUDT/WriteUDT?
--- End quote ---
Unsigned tag types are not yet supported, but I will look into getting this implemented in the next beta version.
--- End quote ---
Unsigned types were added to the 5580/5380 platform only, v32 and above. Also, Micro800 series. I'm sure you already know but data types for reference (forgive the extra nonsense):
--- Code: ---0xc6: (1, "USINT", '<B'),
0xc7: (2, "UINT", '<H'),
0xc8: (4, "UDINT", '<I'),
0xc9: (8, "LWORD", '<Q'),
0xcb: (8, "LREAL", '<d'),
--- End code ---
Edit: Maybe you are already supporting those types and you were referring to adding support for read/write UDT specifically. My bad if that statement is true...
Archie:
--- Quote from: dmroeder on January 07, 2021, 11:51:16 PM ---
--- Quote from: Archie on January 07, 2021, 09:39:40 PM ---
--- Quote from: marcowy on January 06, 2021, 05:07:08 PM ---According to this SINT = SByte. But what about USINT? Can I delcare it as Byte and read/write it with ReadUDT/WriteUDT?
--- End quote ---
Unsigned tag types are not yet supported, but I will look into getting this implemented in the next beta version.
--- End quote ---
Unsigned types were added to the 5580/5380 platform only, v32 and above. Also, Micro800 series. I'm sure you already know but data types for reference (forgive the extra nonsense):
--- Code: ---0xc6: (1, "USINT", '<B'),
0xc7: (2, "UINT", '<H'),
0xc8: (4, "UDINT", '<I'),
0xc9: (8, "LWORD", '<Q'),
0xcb: (8, "LREAL", '<d'),
--- End code ---
Edit: Maybe you are already supporting those types and you were referring to adding support for read/write UDT specifically. My bad if that statement is true...
--- End quote ---
I thought it needed to be implemented for both reading individual tags and parsing when Reading/writing UDTs, but after looking I see support for those new tag types were already implemented when reading them individually. So only parsing the UDT byte steam into equivalent classes needs to be implemented.
dmroeder:
--- Quote from: Archie on January 08, 2021, 02:32:59 AM ---
--- Quote from: dmroeder on January 07, 2021, 11:51:16 PM ---
--- Quote from: Archie on January 07, 2021, 09:39:40 PM ---
--- Quote from: marcowy on January 06, 2021, 05:07:08 PM ---According to this SINT = SByte. But what about USINT? Can I delcare it as Byte and read/write it with ReadUDT/WriteUDT?
--- End quote ---
Unsigned tag types are not yet supported, but I will look into getting this implemented in the next beta version.
--- End quote ---
Unsigned types were added to the 5580/5380 platform only, v32 and above. Also, Micro800 series. I'm sure you already know but data types for reference (forgive the extra nonsense):
--- Code: ---0xc6: (1, "USINT", '<B'),
0xc7: (2, "UINT", '<H'),
0xc8: (4, "UDINT", '<I'),
0xc9: (8, "LWORD", '<Q'),
0xcb: (8, "LREAL", '<d'),
--- End code ---
Edit: Maybe you are already supporting those types and you were referring to adding support for read/write UDT specifically. My bad if that statement is true...
--- End quote ---
I thought it needed to be implemented for both reading individual tags and parsing when Reading/writing UDTs, but after looking I see support for those new tag types were already implemented when reading them individually. So only parsing the UDT byte steam into equivalent classes needs to be implemented.
--- End quote ---
After I had posted, I thought I remembered us discussing this when v32 first came out. I remember borrowing hardware to test this in python.
diegokarts@gmail.com:
I need read a Array of UDT with size 10, in C#.
I have a error in command .ReadUDT. See attachments.
public struct UDT
{
public Int32 Yr;
public Int32 Mo;
public Int32 Da;
public Int32 Hr;
public Int32 Min;
public Int32 Sec;
public Int32 uSec;
}
UDT[] Dates = new UDT[10];
Dates = CLXCom.ReadUDT("Dates",10);
Godra:
Your code should probably be more similar to this:
--- Code: --- public struct TimeUDT
{
public int Yr;
public int Mo;
public int Da;
public int Hr;
public int Min;
public int Sec;
public int uSec;
}
private void MainForm_Load(object sender, EventArgs e)
{
var Dates = CLXCom.ReadUDT<TimeUDT>("Dates[0]", 10);
}
--- End code ---
Navigation
[0] Message Index
[*] Previous page
Go to full version