Giter VIP home page Giter VIP logo

rogue's People

Contributors

abunimeh avatar bengineerd avatar bhill-slac avatar cdollar7 avatar daniellee0115 avatar ddoering avatar jesusvasquez333 avatar jjl772 avatar jk0rah avatar jmdewart avatar jumdz avatar leosap avatar mkwiatko avatar mskoufis avatar nichollsharrisonj avatar nwhitehorn avatar omar-moreno avatar pbutti avatar ruck314 avatar russell-slac avatar slacrherbst avatar thatweaver avatar valmar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rogue's Issues

Add timestamps to logging functions

I am looking throug failure logs for Simons Observatory's SMuRF software, and am finding that it would be really nice to have timestamps on more log messages. For instance, here is a sample of the logs from an old run:

ERROR:pyrogue.Variable.RemoteVariable.AMCc.FpgaTopLevel.AppTop.AppCore.SysgenCryo.Base[7].CryoChannels.etaI[28]:int too big to convert
Traceback (most recent call last):
  File "/usr/local/src/rogue/python/pyrogue/_Variable.py", line 324, in set
    self._block.set(self, value)
  File "/usr/local/src/rogue/python/pyrogue/_Block.py", line 362, in set
    ba = var._base.toBytes(value)
  File "/usr/local/src/rogue/python/pyrogue/_Model.py", line 128, in toBytes
    ba = value.to_bytes(byteCount(self.bitSize), self.endianness, signed=True)
OverflowError: int too big to convert
ERROR:pyrogue.Variable.RemoteVariable.AMCc.FpgaTopLevel.AppTop.AppCore.SysgenCryo.Base[7].CryoChannels.etaI[28]:Error setting value '-50008' to variable 'AMCc.FpgaTopLevel.AppTop.AppCore.SysgenCryo.          Base[7].CryoChannels.etaI[28]' with type Int16. Exception=int too big to convert
1718215269.675174:pyrogue.epicsV3.Value: Error setting value from epics: smurf_server_s7:AMCc:FpgaTopLevel:AppTop:AppCore:SysgenCryo:Base[7]:CryoChannels:etaMagArray

/tmp/fw/rogue_MicrowaveMuxBpEthGen2_v1.1.0.zip/python/CryoDet/DspCoreLib/CryoDetCmbHcd/_SerialEtaScan.py:88: RuntimeWarning: divide by zero encountered in scalar divide
ERROR:pyrogue.PollQueue:'Memory Error for AMCc.FpgaTopLevel.AppTop.DaqMuxV2[1].DbgInputValid at address 0xb000002c Timeout waiting for register transaction message response'
ERROR:pyrogue.PollQueue:'Memory Error for AMCc.FpgaTopLevel.AmcCarrierCore.SwRssiServer[1].RetransmitCnt at address 0xa01104c Timeout waiting for register transaction message response'
ERROR:pyrogue.PollQueue:'Memory Error for AMCc.FpgaTopLevel.AppTop.DaqMuxV2[1].TriggerSwStatus at address 0xb0000004 Timeout waiting for register transaction message response'
ERROR:pyrogue.PollQueue:'Memory Error for AMCc.FpgaTopLevel.AmcCarrierCore.EM22xx.READ_TEMPERATURE_1 at address 0xd000234 Timeout waiting for register transaction message response'
ERROR:pyrogue.PollQueue:'Memory Error for AMCc.FpgaTopLevel.AmcCarrierCore.AxiVersion.UpTimeCnt at address 0x000008 Timeout waiting for register transaction message response'
ERROR:pyrogue.PollQueue:'Memory Error for AMCc.FpgaTopLevel.AppTop.AppTopJesd[0].JesdRx.RawData[5] at address 0xc0000154 Timeout waiting for register transaction message response'

There are some timestamps here, but the Timeout waiting for register transaction message response errors have none. Can we add timestamps to all rogue log messages?

Bad access to shared pointer when creating UDP client and server

Constructor of rogue::protocols::udp::Client and rogue::protocols::udp::Server spawns a runThread. Inside this thread a shared_from_this() is called, that returns a shared pointer of the constructed object.
In the case where the object is already constructed, e.g. shared pointer is not weak it works fine.
However, if the spawned thread runThread tries to generate a shared pointer before the object is constructed it throws std::bad_weak_ptr.

Now, it seems that runThread of Client and Server has a usleep(1000); to overcome this problem. However, this is not always sufficient. The runThread shall wait until the object is created, i.e. shared pointer was created out of it.

For example with use of mutex

//! Class creation
rpu::ServerPtr rpu::Server::create(uint16_t port, bool jumbo)
{
   rpu::ServerPtr r = std::make_shared<rpu::Server>(port, jumbo);
   r->constructed();
   return (r);
}

//! Set object is constructed
void rpu::Server::constructed()
{
   mutex_.unlock();
}

//! Run thread
void rpu::Server::runThread()
{
   ris::BufferPtr buff;
   ris::FramePtr frame;
   fd_set fds;
   int32_t res;
   struct timeval tout;
   struct sockaddr_in tmpAddr;
   uint32_t tmpLen;
   uint32_t avail;

   udpLog_->logThreadId();
   std::lock_guard<std::recursive_mutex> lk(mutex_); // wait for construction to end

   // Preallocate frame
   frame = ris::Pool::acceptReq(maxPayload(), false);

   while (threadEn_)
   {

UDP Server and Client internal thread may cause std::bad_weak_ptr exception to be thrown

shared_from_this() may be called before the object and shared_ptr are fully initialized. This causes std::bad_weak_ptr exception and crashes the application.

Trace Server:
rpu::Server::runThread()
-- ris::Pool::acceptReq(maxPayload(),false)
---- allocBuffer(size,&frSize)
------ shared_from_this()

Trace Client:
rpu::Client::runThread()
-- ris::Pool::acceptReq(maxPayload(),false)
---- allocBuffer(size,&frSize)
------ shared_from_this()

Proposed fix:

auto weakPtr = weak_from_this();
auto sharedPtr = weakPtr.lock();

while (!sharedPtr) {
    std::this_thread::yield();
    sharedPtr = weakPtr.lock();
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.