Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CA PV: Write any 32 bit long, signed or unsigned #2554

Merged
merged 2 commits into from
Feb 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions core/pv/src/main/java/org/phoebus/pv/ca/JCA_PV.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2017-2021 Oak Ridge National Laboratory.
* Copyright (c) 2017-2023 Oak Ridge National Laboratory.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
Expand Down Expand Up @@ -525,10 +525,16 @@ else if (new_value instanceof Integer [])
else if (new_value instanceof Long)
{
final Long orig = (Long) new_value;
// ChannelAccess doesn't support long
if (orig.longValue() == orig.intValue())
// ChannelAccess doesn't support long.
// If value is small, write as int
//
// Channel Access doesn't support unsigned, either.
// Will the number fit into 32 bits?
// As an unsigned long it may be beyond the largest int,
// but if it fits into a signed int, write as such
if (orig.longValue() == orig.intValue() ||
Integer.toUnsignedLong(orig.intValue()) == orig.longValue())
{
// If value is small, write as int
final int val = orig.intValue();
if (put_listener != null)
channel.put(val, put_listener);
Expand Down